Proto to BallerinaIf you already have protocol buffer file for your service(s) you can use that to autogenerate Ballerina source code.
Currently, Ballerina supports two types of code generation. |
syntax = "proto3";
service helloWorld {
rpc hello(HelloRequest) returns (HelloResponse);
rpc bye(ByeRequest) returns (ByeResponse);
}
message HelloRequest {
string name = 1;
}
message HelloResponse {
string message = 1;
}
message ByeRequest {
string greet = 1;
}
message ByeResponse {
string say = 1;
}
# Execute the command below in the Ballerina tools distribution to generate the mock service.
bal grpc --input proto_to_ballerina.proto --mode service --output service
# Execute the command below in the Ballerina tools distribution to generate the client endpoint and the stub file.
bal grpc --input proto_to_ballerina.proto --mode client --output client
# Execute the command below in the Ballerina tools distribution to generate the stub file.
bal grpc --input proto_to_ballerina.proto