First stage of #18
This the gRPC server and Vereign Rest API client architecture.
vereign::restapi::Client
can make HTTP POST requests to Vereign Rest API.
The client is async, but additionally provides blocking APIs with futures.
The client maintains a single connection with the server for a given idle timeout period.
All the post requests are executed sequentially.
The connection is restored when needed.
Decorates the vereign::restapi::Client
by maintaining authenticated session.
vereign::service::gen::PassportService
This service will be generated.
It uses the vereign::restapi::ClientSession
to make the POST requests.
Will contain methods for calling all the endpoints that start with /passport
.
vereign::service::PassportService
Extends the generated vereign::service::gen::PassportService
.
Adds a new API ListPassportsManually
.
vereign::grpc::gen::PassportAPI
This is the layer that is provided to the clients of the library, through a gRPC API.
Uses the vereign::service::PassportService
to forward all generated API calls.
vereign::grpc::PassportAPI
Extends the generated vereign::grpc::gen::PassportAPI
.
Adds a new API ListPassportsManually
.
vereign::grpc::Server
Bootstraps the gRPC server, all the Vereign Services and the HTTP Client Session.
Example request path:
gRPC Client -> vereign::grpc::PassportAPI
-> vereign::service::PassportService
-> vereign::restapi::ClientSession
-> vereign::restapi::Client
-> restapi server
The requests and responses are protobuf objects, that are serialized/deserialized as JSON inside the vereign::restapi::Client
.
Some of the proto definitions also need to be generated. In this example the proto files that will be generated are:
This means that there are two steps of generation, first our generator will generate these proto files,
and then the protoc
will be used for generating the protobuf/gRPC code.
IMPORTANT: I included the cpp/src/vereign/proto/code.vereign.com/code/viam-apis
repository as git submodule
at /src/vereign/proto/code.vereign.com
. That way i was able to use the proto definitions from
code.vereign.com/code/viam-apis/entities-management-agent/api/api.proto
, and in particular the message ListPassportsFormResponse
inside /src/vereign/proto/passport_types.gen.proto
uses api.EntityMessage_V2
message.
I see that this repo cpp/src/vereign/proto/code.vereign.com/code/viam-apis
contains both proto definitions and generated source code. It will be better if we have all proto definitions in all projects in separate git repositories, so that
different users can add them as git submodules and generate for the language they use.