Hi all,

gRPC is a modern, open-source remote procedure call (RPC) framework. Due to
the advantages in terms of performance and usability, grpc is becoming
popular these days. The idea is to provide support for grpc in
microgateway. As the initial step, we would consider the scenario where
both the client and server communicate via grpc.

Grpc is built on top of http/2. The major difference is how that protocol
encodes the payload. And the structure of header values remains the same as
http/2 call. Therefore we can treat the grpc call as same as http/2
request. I have tested using ballerina passthrough against grpc client and
grpc server. And it worked.

The basic design would be like this.
[image: image.png]

Authentication and Authorization can be provided via the HTTP filters that
are already available in the gateway. Mutual SSL also supported. L7 load
balancing has already been available since ballerina load balancing is done
based on HTTP requests.

The grpc client could be unary or streaming. Grpc server also can be unary
service or streaming service. When both the client and service are unary,
we can do the throttling by just considering the traffic as HTTP/2 traffic.
But when if we consider a server, which expects a streaming client, we need
to consider how to define the throttling. When there is a streaming client,
only one HTTP request is sent and all the messages in the stream will be
routed as data frames inside that HTTP request. If we do the throttling as
"requests per second" (which already exists for HTTP/2), it means that we
are allowing to initiate that number of streams within a second. Then, we
do not know how much messages are going that stream. In my opinion, it is
also not a bad idea to define the throttling based on HTTP request as the
server always expect a stream. Somehow, we need to define throttling when
there is a streaming client or a service.

To create grpc client and a server, it is required to have a ".proto" file.
It contains all the methods available in the grpc server. And it is
identical to the path in HTTP resource. Let's consider the following
example.

syntax = "proto3";
import "google/protobuf/wrappers.proto";
service Chat {
        rpc chat (stream ChatMessage)
                        returns (stream google.protobuf.StringValue);
}
message ChatMessage {
        string name = 1;
        string message = 2;
}

When a grpc call is made from a client, this is how the HTTP request
headers look like,
[:path: /Chat/chat, :method: POST, :scheme: http, :authority:
localhost:50051, scheme: https, authority: https://localhost:9099,
grpc-accept-encoding: gzip, content-type: application/grpc, te: trailers,
user-agent: ballerina/0.991.0]

As you can see, the resource URL should be <server_address>/Chat/chat.
Therefore we can figure out the available resources using the proto file.
But the problem here is how to ask the user to provide the server
endpoints, basepath, security type, scopes etc. It is not possible to add
them in the proto file unlike in openAPI definition. Either we have to ask
the user to import separate file including all these properties or we can
ask them to provide as command-line arguments while importing.

Any suggestions or concerns are highly appreciated.

Regards,
Viraj
-- 
*Viraj Salaka Gamage* | Software Engineer | WSO2 Inc.
+94 710 618 178
GET INTEGRATION AGILE
Integration Agility for Digitally Driven Business
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to