grpc-spring-boot-starter travis-ci

Spring Boot starter module for gRPC framework.

Grpc Spring Boot Starter

Join the chat at https://gitter.im/yidongnan/grpc-spring-boot-starter

Build Status Maven Central

README: English | 中文

Features

Auto configuring and run the embedded gRPC server with @GrpcService-enabled beans as part of spring-boot application.

Support Spring Cloud(registe services to consul or eureka and fetch gRPC server information)

Support Spring Sleuth to trace application

Support global and customer gRPC server/client interceptors

Support keepalive

Usage

gRPC server

To add a dependency using Maven, use the following:

<dependency>
  <groupId>net.devh</groupId>
  <artifactId>grpc-server-spring-boot-starter</artifactId>
  <version>1.0.1.RELEASE</version>
</dependency>

To add a dependency using Gradle:

dependencies {
  compile 'net.devh:grpc-server-spring-boot-starter:1.0.1.RELEASE'
}

Annotate your server interface implementation(s) with @GrpcService

@GrpcService(GreeterGrpc.class)
public class GrpcServerService extends GreeterGrpc.GreeterImplBase {

    @Override
    public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = HelloReply.newBuilder().setMessage("Hello =============> " + req.getName()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}

gRPC client

To add a dependency using Maven, use the following:

<dependency>
  <groupId>net.devh</groupId>
  <artifactId>grpc-client-spring-boot-starter</artifactId>
  <version>1.0.1.RELEASE</version>
</dependency>

To add a dependency using Gradle:

dependencies {
  compile 'net.devh:grpc-client-spring-boot-starter:1.0.1.RELEASE'
}

Use @GrpcClient("gRPC server name") annotation or grpcChannelFactory.createChannel("gRPC server name") to get Channel

@GrpcClient("gRPC server name")
private Channel serverChannel;

set gRPC host and port in application.properties, default host is 0.0.0.0 and default port is 9090

grpc.server.port=
grpc.server.host=

gRPC request

GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverChannel);
HelloReply response = stub.sayHello(HelloRequest.newBuilder().setName(name).build());

set gRPC server host and port in application.properties, default host is [127.0.0.1] and default port is [9090]

grpc.client.(gRPC server name).host[0]=
grpc.client.(gRPC server name).port[0]=

Version Compatibility with gRPC-java

Note: The version numbers below are only examples

Project Version gRPC-java Version
1.0.1.RELEASE 1.1.2
1.0.0.RELEASE 1.0.3

Show case

https://github.com/yidongnan/grpc-spring-boot-starter/tree/master/examples

Credits

Related Repositories

grpc-spring-boot-starter

grpc-spring-boot-starter

Spring Boot starter module for gRPC framework. ...

grpc-spring-boot-starter

grpc-spring-boot-starter

Spring Boot starter module for gRPC framework. ...

grpc-spring-boot-starter

grpc-spring-boot-starter

SpringBoot Starter for gRPC ...

grpc-spring-boot-starter

grpc-spring-boot-starter

Spring Boot starter module for Google RPC ...


Top Contributors

yidongnan backjo gitter-badger

Releases

-   v1.2.0.RELEASE zip tar
-   v1.1.1.RELEASE zip tar
-   v1.1.0.RELEASE zip tar
-   v1.0.1.RELEASE zip tar
-   v1.0.0.RELEASE zip tar