As I know, GRPC clients can be generated for any language that support GRPC. However, can the services on the server be implemented using different languages for the same proto file?
For example, I have this proto file:
service Greeter {
rpc SayHello (Request) returns (Reply) {}
}
service Goodbye {
rpc SayGoodBye(Request) returns (Reply) {}
}
message Request {
string name = 1;
}
message Reply {
string message = 1;
}
Can the 2 services Greeter and Goodbye be implemented in different languages, for example:
What about the case when I separate those 2 services into 2 different proto files?
If it can be done in different languages, is it a good practice? The usecase I can think of for this is when all members of the team cannot work in the same language, like when it's hard to recruit new Golang developers and the team needs to recruit some Java developers instead to continue the project.
Proto files are meant to be generic contracts that can be used by many different applications/services that share the same contract. It is a common practice to have the same set of proto files being built for different languages and used by the applications using those languages, without loss of generality.
So yes, Greeter can be implemented in Golang and Goodbye can be implemented in Java, as long as they correctly implement the necessary gRPC interfaces.
You can separate the services in different proto files, but that would depend on how correlated they are. If you are providing a specific set of functionalities that fit reasonably well together, it is a good idea to have in the same proto file. Use your best judgement in this case, the same way you would use when, for instance, you would decide to place a set of Python classes inside the same module.
For your last question on whether using the services on different languages is good/bad practice, keep in mind that gRPC allows many languages based on the same proto contract exactly to allow the protocol to meet different requirements. For instance, you can have a Python client that is a Python API which would be very user friendly, that communicates through gRPC with a C++ server that is intended to leverage C++ performance. As long as you implement the services correctly from the proto contract, you are free to use the language you want considering the requirements of your application.