The Java gRPC Server/Client implementation, using JSON marshaller.
<dependency>
<groupId>com.github.charlemaznable</groupId>
<artifactId>grpc-astray</artifactId>
<version>2024.0.0</version>
</dependency>
<dependency>
<groupId>com.github.charlemaznable</groupId>
<artifactId>grpc-astray</artifactId>
<version>2024.0.1-SNAPSHOT</version>
</dependency>
@GRpcService
public class MyService {
@GRpcMethod
public MyResponse methodName(MyRequest req) {
// 业务逻辑
}
}
启动SpringBoot后, gRPC服务默认监听7018端口.
@GRpcClient("MyService")
@GRpcChannel("service_host:7018")
public interface MyClient {
@GRpcCall
MyResponse methodName(MyRequest req);
}
MyClient client = GRpcFactory.getClient(MyClient.class);
MyResponse resp = client.methodName(req);