It seems gRPC's has not support for service discovery & registry so far

1,652 views
Skip to first unread message

Benson Wang

unread,
Jun 13, 2016, 6:04:15 AM6/13/16
to grp...@googlegroups.com
Deal all,

In our situation, we want to one gRPC server can provide numerous services for different gPRC clients.
We register our services by the way below. But we cannot remove the registered services from gRPC. It seems gRPC's has not support for service discovery & registry so far. Is it in your plan?

for(RegisterEntry service : services){
        //NettyServerBuilder serverBuilder
    serverBuilder.addService((ServerServiceDefinition) service.getServiceDefinition().getServiceObj());
})



Regards,
Benson

Eric Anderson

unread,
Jun 13, 2016, 1:48:34 PM6/13/16
to Benson Wang, grpc-io
On Mon, Jun 13, 2016 at 3:03 AM, Benson Wang <benso...@symbio.com> wrote:
We register our services by the way below. But we cannot remove the registered services from gRPC.

If you want to mutate the services after you start the server, you need to provide your own HandlerRegistry. For example, you can pass a MutableHandlerRegistry (note that this will be renamed to io.grpc.util.MutableHandlerRegistry in the next release).

It seems gRPC's has not support for service discovery & registry so far. Is it in your plan?

Is that related to removing services, or is this a completely separate question?

If it's a separate question, then you want to look at "Name Resolvers." gRPC does not do service discovery itself but allows integrating with a service discovery service via Name Resolvers. Is there a particular service discovery mechanism you would like to use?

Benson Wang

unread,
Jun 14, 2016, 3:54:30 AM6/14/16
to Eric Anderson, grpc-io
Thanks Eric for your feedback.  Could you give me a clue to use "Name Resolvers" to integrate with a service discovery?

Thanks in advances!

Regards,
Benson

Eric Anderson

unread,
Jun 14, 2016, 12:19:25 PM6/14/16
to Benson Wang, grpc-io
On Tue, Jun 14, 2016 at 12:54 AM, Benson Wang <benso...@symbio.com> wrote:
Thanks Eric for your feedback.  Could you give me a clue to use "Name Resolvers" to integrate with a service discovery?

Implement a NameResolver. We use URI schemes to primarily distinguish between resolvers. So a target of dns:///google.com would generally use the DnsNameResolver. In the current version you then register a NameResolver.Factory with NameResolverRegistry.register(). In the next version this is changing. You would make a NameResolverProvider and we will load it from the classpath using ServiceLoader, so no static method calls are necessary before use.

You can find some documentation in the primary grpc repo. But probably the best documentation at this point on targets is the forTarget() method (that I also linked to earlier).

王 梓佳

unread,
Jun 27, 2016, 10:59:30 AM6/27/16
to grpc-io
Dear all,

I tried to use goal protobuf:compile-javanano to generate the code(message and rpc service stub), but i encountered a error "Java NANO_RUNTIME does not support services".
Does the protobuf-maven-plugin has not support on it? also it seem it also doesn't support objective-c code generation, right?  Many thanks!

pom.xml
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.5.0</version>
                <configuration>
                            <checkStaleness>true</checkStaleness>
                    <writeDescriptorSet>true</writeDescriptorSet>
                    <descriptorSetFileName>protos.desc</descriptorSetFileName>
                    <protocArtifact>com.google.protobuf:protoc:3.0.0-beta-3:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:0.14.0:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile-javanano</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Helloworld.proto:
syntax = "proto3";

option java_package = "practices.microservice.demo.protos";

package practices.microservice.demo.protos;

// The greeter service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

Benson Wang

unread,
Jun 27, 2016, 11:06:53 AM6/27/16
to ej...@google.com, grpc-io
Dear Eric,

I tried to use goal protobuf:compile-javanano to generate the code(message and rpc service stub) for android, but i encountered a error "Java NANO_RUNTIME does not support services".
Does the protobuf-maven-plugin has not support rpc service code generation? also it seem it doesn't support objective-c code generation, right?  Many thanks!

Eric Anderson

unread,
Jun 27, 2016, 11:56:36 AM6/27/16
to 王 梓佳, grpc-io
Nano itself doesn't support services, and that's what gRPC does. You just need to pass ignore_services=true to javanano and protoc-gen-grpc-java will generate the services.

So you will need this for nano:
<pluginParameter>ignore_services=true</pluginParameter>

And this for grpc (if using earlier that v0.14.0, then it needs to be nano=true):
<pluginParameter>nano</pluginParameter>

--
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/TY1PR04MB0879129698B497470A211D0CD1210%40TY1PR04MB0879.apcprd04.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages