Although grpc seems great for "microservices" where each service is running in it's own process. Would you expect any challenges if the architecture required multiple services to be running in the same process?
But you can't currently run multiple instances of the same service on the same port, right?
At least not with the standard gRPC+protobuf idiom? Or am I missing something?
To elaborate a bit, in a traditional REST-style API, you can instantiate multiple instances of a handler and map them to multiple HTTP request paths off the same port. For example, your service might route requests tomyserver:80/myapi/foomyserver:80/myapi/barto dynamically created instances of the same handler code (which might, for example, be configured differently at runtime).
Judging by the gRPC+protobuf code samples I've seen, to accomplish something similar, you'd have to define multiple service names in the protobuf IDL code, because the standard message -> handler dispatching logic just looks at ServiceName.MethodName. In statically typed languages, at least, this means you have to write O(N) shims which are declared to implement each service interface (or do the equivalent using runtime code generation).
Or, somewhat better, you could define a "union" service which contains, for every method M in your underlying service with argument message type T, a method M' which takes an argument of typemessage T_prime {string path = 1;T payload = 2;}and implement your own dispatching. Obviously, this comes with the downside that it must be repeated for every RPC type you wish to serve in this fashion.
Or you could put the service instances on different ports, but if you map a lot of instances of the service you end up consuming a lot of ports. This has other disadvantages: port numbers are less mnemonic than paths, and you may have to reconfigure firewalls to open up ranges of ports rather than individual ports.
On Tue, Mar 31, 2015 at 8:08 PM, <keu...@gmail.com> wrote:To elaborate a bit, in a traditional REST-style API, you can instantiate multiple instances of a handler and map them to multiple HTTP request paths off the same port. For example, your service might route requests tomyserver:80/myapi/foomyserver:80/myapi/barto dynamically created instances of the same handler code (which might, for example, be configured differently at runtime).gRPC ≠ REST. gRPC is also not object-oriented conceptually; the RPCs are more of functions than methods.
The core problem is why do you need to expose multiple instances of the same service?
Is there an example of when you need the same service multiple times?
--~k
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/47b96fd6-0455-49d6-808d-3fb19c3a095e%40googlegroups.com.
gRPC, like every RPC system I know of, is inescapably object-oriented in the sense that an RPC has a receiver. Currently, in gRPC+proto, the receiver is named by the host:port/servicetype of the target.
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/a374af44-d06f-4fe3-bfce-a30550e596f0%40googlegroups.com.
Right know, I added a layer between the ServiceDevinitions list and the server. So the server contains a list of components instead of ServiceDefinitions, and the definitions are know in my component class. The component class only contains the prefix added to all service handles and can be activated and deactivated. Since modules can be added at runtime in my framework, I need to change the list of services supported at runtime. The server implementation does not allow this, since the normal use case would be to stop the server. So if I would want to use multiple ports, I still could do everything within the regular standard. But this isn't possible, even if I prefer it since it makes everything easier.
This would work, but then I would need to have the identifier added to every request and also need to find a way for accessing this identifier, since the framework is generated once and not with every build. Therefor it doesn't know the generated classes and can only work on the serialized data. Would be more work to achieve this.
Right know, I added a layer between the ServiceDevinitions list and the server. So the server contains a list of components instead of ServiceDefinitions, and the definitions are know in my component class. The component class only contains the prefix added to all service handles and can be activated and deactivated. Since modules can be added at runtime in my framework, I need to change the list of services supported at runtime. The server implementation does not allow this, since the normal use case would be to stop the server. So if I would want to use multiple ports, I still could do everything within the regular standard. But this isn't possible, even if I prefer it since it makes everything easier.
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/2fe55400-6db5-4ac2-8820-024e7076d4d8%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/9689ab85-7401-424b-b4d5-a07b9a38fdec%40googlegroups.com.
Hey gRPC community, so I think I've got a similiar problem when trying to think up a good gRPC API for my IoT server which would replace its current REST interface.
The scenario I'm working on involves a server/home hub thing that controls any number of devices, currently mostly different kind of lamps.
So on the one hand there is a service that just provides listings of devices which is easily mapped to gRPC. But then every device provides functionality too,
with both the number of devices only known at runtime and several different device types with a hierarchy. In Go the device types are modeled like this:
https://github.com/niklas88/feel-at-home-server/blob/master/devices/lampbase.go
So now I'm wondering how to best map this to a gRPC API. The only thing I have come up with until now is having one controlling service for each device type
which takes some kind of deviceId as one of each of its methods arguments and then uses that to lookup the device. I'm not sure whether I have missed some kind ofmixin concept but I guess each service would also need to copy all methods the device supports? I'm sure I could wrap this in a nice API but it still feels like somewhat ofa clutch so I'd be thankful for suggestions.
--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/b6653e4b-4954-4921-9d82-0b0471673d62%40googlegroups.com.
So on the one hand there is a service that just provides listings of devices which is easily mapped to gRPC. But then every device provides functionality too,
with both the number of devices only known at runtime and several different device types with a hierarchy. In Go the device types are modeled like this:
https://github.com/niklas88/feel-at-home-server/blob/master/devices/lampbase.go
So now I'm wondering how to best map this to a gRPC API. The only thing I have come up with until now is having one controlling service for each device typewhich takes some kind of deviceId as one of each of its methods arguments and then uses that to lookup the device.
For C++ gRPC I do not currently see any option for this, I cannot add more than one service in builder.RegisterService.Is there some other way to do this
Hey Eric. He asked about the C++ API and not C# :) I didn't answer since I don't know the C++ API.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&obj_detect_svc);
builder.RegisterService(&serverCheck);
std::unique_ptr<Server> server(builder.BuildAndStart());
On Thursday, March 23, 2017 at 11:27:49 AM UTC+5:30, falco...@gmail.com wrote:Hey Eric. He asked about the C++ API and not C# :) I didn't answer since I don't know the C++ API.
I thought I had deleted my post; Realize now that mail would have been triggered. Initially because of another error from Cient side ,I thought calling RegisterService twice was not working. But it is working thanks;builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&obj_detect_svc);
builder.RegisterService(&serverCheck);
std::unique_ptr<Server> server(builder.BuildAndStart());(I opened this thread as Google search was pointing this as the most relevant and thought updating it may help others (sorry was using this like StackOverflow) )