grpc-spring-boot-starter icon indicating copy to clipboard operation
grpc-spring-boot-starter copied to clipboard

The grpc consumer side is too cumbersome to use

Open thousmile opened this issue 2 years ago • 1 comments

Consumer side, it's too troublesome to use:

@EnableEurekaClient @Component public class GreeterServiceConsumer { @Autowired private EurekaClient client;

public void greet(String name) {
    final InstanceInfo instanceInfo = client.getNextServerFromEureka("my-service-name", false);//(1)
    final ManagedChannel channel = ManagedChannelBuilder.forAddress(instanceInfo.getIPAddr(), instanceInfo.getPort())
            .usePlaintext()
            .build(); //(2)
    final GreeterServiceGrpc.GreeterServiceFutureStub stub = GreeterServiceGrpc.newFutureStub(channel); //(3)
    stub.greet(name); //(4)
}

}

such as:

@EnableEurekaClient @Component public class GreeterServiceConsumer {

@GrpcClient("gRPC server name")
private GreeterServiceGrpc.GreeterBlockingStub stub; //(1)

public void greet(String name) {
    stub.greet(name); //(2)
}

}

thousmile avatar Oct 12 '22 13:10 thousmile

@jvmlet Is there any update about this enhancement?

omutas avatar Jun 06 '23 12:06 omutas