APiGen gRPC Module
gRPC support for inter-service communication in APiGen applications.
Features
- Server Infrastructure: GrpcServer wrapper with fluent builder API
- Client Infrastructure: GrpcChannelFactory for managed channel creation
- Interceptors: Logging, Authentication, and Exception handling
- Health Checks: HealthServiceManager for service health monitoring
- Proto Definitions: Common types (pagination, errors, audit info)
Quick Start
1. Enable gRPC
yaml
apigen:
grpc:
enabled: true
server:
port: 90902. Create a gRPC Server
java
@Configuration
public class GrpcServerConfig {
@Bean
public GrpcServer grpcServer(
List<BindableService> services,
List<ServerInterceptor> interceptors) throws IOException {
return GrpcServer.builder(9090)
.addServices(services)
.addInterceptors(interceptors)
.build()
.start();
}
}3. Create a Client
java
@Service
public class ProductClient {
private final GrpcChannelFactory channelFactory;
private final ProductServiceGrpc.ProductServiceBlockingStub stub;
public ProductClient(GrpcChannelFactory channelFactory) {
this.channelFactory = channelFactory;
ManagedChannel channel = channelFactory.getChannel("product-service:9090", true);
this.stub = ProductServiceGrpc.newBlockingStub(channel);
}
}Configuration Properties
| Property | Default | Description |
|---|---|---|
apigen.grpc.enabled | false | Enable gRPC support |
apigen.grpc.server.port | 9090 | gRPC server port |
apigen.grpc.client.deadline-ms | 10000 | Default deadline |
apigen.grpc.client.use-plaintext | false | Use plaintext (no TLS) |