Documentation
¶
Index ¶
- Constants
- Variables
- func AsGrpcService(description *grpc.ServiceDesc, constructor any) fx.Option
- func CtxLogger(ctx context.Context) *fxlogger.Logger
- func CtxTracer(ctx context.Context) trace.Tracer
- func NewFxGrpcServer(p FxGrpcServerParam) (*grpc.Server, error)
- func RegisterGrpcService(grpcServiceRegistration *GrpcServiceRegistration) fx.Option
- func StartFxGrpcServer() fx.Option
- type DefaultGrpcServerFactory
- type FxGrpcServerParam
- type FxGrpcServiceRegistryParam
- type GrpcHealthCheckServer
- type GrpcPanicRecoveryHandler
- type GrpcServerFactory
- type GrpcServerOption
- type GrpcService
- type GrpcServiceDefinition
- type GrpcServiceRegistration
- type GrpcServiceRegistry
- type LoggerInterceptor
- type WrappedStream
Constants ¶
View Source
const DefaultPort = 50051
Variables ¶
View Source
var FxGrpcServerModule = fx.Module( "grpc-server", fx.Provide( NewDefaultGrpcServerFactory, NewFxGrpcServiceRegistry, NewFxGrpcServer, ), )
Functions ¶
func AsGrpcService ¶
func AsGrpcService(description *grpc.ServiceDesc, constructor any) fx.Option
func NewFxGrpcServer ¶
func NewFxGrpcServer(p FxGrpcServerParam) (*grpc.Server, error)
func RegisterGrpcService ¶
func RegisterGrpcService(grpcServiceRegistration *GrpcServiceRegistration) fx.Option
func StartFxGrpcServer ¶
Types ¶
type DefaultGrpcServerFactory ¶
type DefaultGrpcServerFactory struct{}
func (*DefaultGrpcServerFactory) Create ¶
func (f *DefaultGrpcServerFactory) Create(options ...GrpcServerOption) (*grpc.Server, error)
type FxGrpcServerParam ¶
type FxGrpcServerParam struct { fx.In LifeCycle fx.Lifecycle Factory GrpcServerFactory Registry *GrpcServiceRegistry Config *fxconfig.Config Logger *fxlogger.Logger HealthChecker *fxhealthchecker.HealthChecker }
type FxGrpcServiceRegistryParam ¶
type FxGrpcServiceRegistryParam struct { fx.In GrpcServices []any `group:"grpc-server-services"` GrpcServicesDefinitions []GrpcServiceDefinition `group:"grpc-server-service-definitions"` }
type GrpcHealthCheckServer ¶
type GrpcHealthCheckServer struct { grpc_health_v1.UnimplementedHealthServer // contains filtered or unexported fields }
func NewGrpcHealthCheckServer ¶
func NewGrpcHealthCheckServer(healthChecker *fxhealthchecker.HealthChecker, logger *fxlogger.Logger) *GrpcHealthCheckServer
func (*GrpcHealthCheckServer) Check ¶
func (s *GrpcHealthCheckServer) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
func (*GrpcHealthCheckServer) Watch ¶
func (s *GrpcHealthCheckServer) Watch(in *grpc_health_v1.HealthCheckRequest, watchServer grpc_health_v1.Health_WatchServer) error
type GrpcPanicRecoveryHandler ¶
type GrpcPanicRecoveryHandler struct {
// contains filtered or unexported fields
}
func NewGrpcPanicRecoveryHandler ¶
func NewGrpcPanicRecoveryHandler(config *fxconfig.Config, logger *fxlogger.Logger) *GrpcPanicRecoveryHandler
func (*GrpcPanicRecoveryHandler) Handle ¶
func (h *GrpcPanicRecoveryHandler) Handle() func(any) error
type GrpcServerFactory ¶
type GrpcServerFactory interface {
Create(options ...GrpcServerOption) (*grpc.Server, error)
}
func NewDefaultGrpcServerFactory ¶
func NewDefaultGrpcServerFactory() GrpcServerFactory
type GrpcServerOption ¶
type GrpcServerOption func(o *options)
func WithReflection ¶
func WithReflection(r bool) GrpcServerOption
func WithServerOptions ¶
func WithServerOptions(s ...grpc.ServerOption) GrpcServerOption
type GrpcService ¶
type GrpcService interface { Description() *grpc.ServiceDesc Implementation() any }
type GrpcServiceDefinition ¶
type GrpcServiceDefinition interface { Description() *grpc.ServiceDesc ReturnType() string }
type GrpcServiceRegistration ¶
type GrpcServiceRegistration struct {
// contains filtered or unexported fields
}
func NewGrpcServiceRegistration ¶
func NewGrpcServiceRegistration(description *grpc.ServiceDesc, constructor any) *GrpcServiceRegistration
func (*GrpcServiceRegistration) Constructor ¶
func (r *GrpcServiceRegistration) Constructor() any
func (*GrpcServiceRegistration) Description ¶
func (r *GrpcServiceRegistration) Description() *grpc.ServiceDesc
type GrpcServiceRegistry ¶
type GrpcServiceRegistry struct {
// contains filtered or unexported fields
}
func NewFxGrpcServiceRegistry ¶
func NewFxGrpcServiceRegistry(p FxGrpcServiceRegistryParam) *GrpcServiceRegistry
func (*GrpcServiceRegistry) ResolveGrpcServices ¶
func (r *GrpcServiceRegistry) ResolveGrpcServices() ([]GrpcService, error)
type LoggerInterceptor ¶
type LoggerInterceptor struct {
// contains filtered or unexported fields
}
func NewLoggerInterceptor ¶
func NewLoggerInterceptor(logger *fxlogger.Logger) *LoggerInterceptor
func (*LoggerInterceptor) StreamInterceptor ¶
func (i *LoggerInterceptor) StreamInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
func (*LoggerInterceptor) UnaryInterceptor ¶
func (i *LoggerInterceptor) UnaryInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
type WrappedStream ¶
type WrappedStream struct { grpc.ServerStream // contains filtered or unexported fields }
func NewWrappedStream ¶
func NewWrappedStream(ss grpc.ServerStream, ctx context.Context) *WrappedStream
func (*WrappedStream) Context ¶
func (w *WrappedStream) Context() context.Context
Click to show internal directories.
Click to hide internal directories.