gRPC

Functions

Public API reference for the gRPC extension

Extension Entry Points

FunctionDescription
NewExtension(opts ...ConfigOption) forge.ExtensionCreate the gRPC extension with functional options
NewExtensionWithConfig(config Config) forge.ExtensionCreate the gRPC extension with a complete config
DefaultConfig() ConfigReturns the default configuration

GRPC Interface -- Service Registration

MethodDescription
RegisterService(desc *grpc.ServiceDesc, impl any)Register a gRPC service implementation
GetServiceInfo() []ServiceInfoList all registered services and their methods

GRPC Interface -- Server Lifecycle

MethodDescription
Start(ctx) errorStart the gRPC server listener
Stop(ctx) errorGraceful shutdown of the server
Health(ctx) errorRun health checks on registered services

GRPC Interface -- Interceptors

MethodDescription
AddUnaryInterceptor(interceptor)Add a unary server interceptor
AddStreamInterceptor(interceptor)Add a stream server interceptor

GRPC Interface -- Health

MethodDescription
RegisterHealthChecker(name, checker)Register a named health checker
SetServingStatus(service, status)Set the serving status for a service

GRPC Interface -- Stats

MethodDescription
Stats() ServerStatsGet server statistics
GetServer() *grpc.ServerAccess the underlying grpc.Server

Key Types

ServiceInfo

FieldTypePurpose
NamestringFully qualified service name
Methods[]MethodInfoService methods
DescriptionstringService description

MethodInfo

FieldTypePurpose
NamestringMethod name
IsClientStreamboolClient streams requests
IsServerStreamboolServer streams responses
InputTypestringInput message type
OutputTypestringOutput message type

How is this guide?

On this page