this is common way of gRPC Nacos Java integration. Please feel free to add more features with this repo by sending pull requests and raising a issue.
- grpc client usage
- grpc server builder and starter
- integrate with Nacos
- Automatic service registration and discovery
- Round robin LoadBalancer which supported by gRPC
Latest stable Apache Maven, Maven 3.2.5 or above. Note that this is build-time requirement.
Runtime requirement: JDK 8 is a recommend to run this application.
You may clone this project and step into grpc-nacos-java sub directory before read on.
# git clone https://github.com/Moriadry/grpc-nacos-java
# cd grpc-nacos-java
Run the following command to build the project(Java 1.8 is required to build the master branch).
mvn clean install
Start a Nacos naming server is a must.
Check the necessary config here You can copy this proto to your project. And do pay attention to the config usage.
`nacos_uri` means the uri of Nacos naming uri to register.
`grpc_nacos_port` means the port of Grpc server,which is needed by both server and client.
use `GrpcNacosOptions.getDescriptor().getOptions().getExtension(GrpcNacosProto.grpcNacosPort)` to get configuration of grpc port,
and `GrpcNacosOptions.getDescriptor().getOptions().getExtension(GrpcNacosProto.nacosUri)` represents the configuration of nacos registry url.
cd grpc-nacos-java-example
mvn exec:java@server-demo
mvn exec:java@client-demo
Calling result will be print out on the screen.
-
Golang will be supported when nacos-go-sdk provided.
-
More features welcome to be requested.
gRPC Nacos java is under the Apache 2.0 license. See the LICENSE file for details.