Initial Release
The aim of this proof of concept is to show how the gRPC protocl can be implemented with the IRIS ineroperabilty module.
On this schema, we can see that the gRPC Service is hosted by IRIS.
This service must invoke the IRIS interoperability module. For that it transforms the protobuf messages to IRIS messages.
The gRPC client is host by a Flask server for demo purpose, the gRPC client can also be invoke by the python script.
syntax = "proto3"; package users;
service Users {
rpc CreateUser (users.CreateUserRequest) returns (users.CreateUserResponse);
rpc GetUser (users.GetUserRequest) returns (users.GetUserResponse);
}message User {
uint32 id = 1;
string name = 2;
string dob = 3;
string company = 4;
string phone = 5;
string title = 6;}
message CreateUserRequest {
User user = 1;
}message CreateUserResponse {
User user = 1;
}message GetUserRequest {
uint32 id = 1;
}
message GetUserResponse {
User user = 1;
}
This file is in ./misc/proto/users
This file holds the definition of the gRPC implementation, it’s kinda the swagger spec.
To create the implementation classes you have to invoke this command :
python3 -m grpc_tools.protoc \
--proto_path=./misc/proto/users/ \
--python_out=src/python/grpc/ \
--grpc_python_out=src/python/grpc/ \
./misc/proto/users/users.proto
This command generate two files :
This module is in ./src/python/grpc/
This module has on class User.
This class is a dataclass that represents a user.
This class is used to store user information.
This class is used to serialize and deserialize user information to protobuf.
This class is used in the IRIS messages.
This module is in ./src/python/grpc/
This module is used to create a server for the gRPC service.
This module has the following classes:
This module has the following functions:
UsersService has the following functions:
This module is in ./src/python/grpc/
This module is used to create a client for the gRPC service.
This module has the following classes:
This module has the following functions:
The UsersClient class has the following methods:
__init__
: create a new stub from the channelThis module is in ./src/python/grpc/
This module is the flask app to server the gRCP client
This module has the following classes:
This module has the following functions:
docker-compose up
Play with it :
POST http://localhost:8080/users HTTP/1.1 Content-Type: application/json
{
"company": "tesdfst",
"dob": "0001-01-01",
"name": "fsd",
"phone": "fdsffdsf",
"title": "sfd"
}
GET http://localhost:8080/users/1 HTTP/1.1