Documentation ¶
Index ¶
- Constants
- Variables
- func AsGrpcServerOptions(options ...grpc.ServerOption) fx.Option
- func AsGrpcServerService(constructor any, description *grpc.ServiceDesc) fx.Option
- func AsGrpcServerStreamInterceptor(constructor any) fx.Option
- func AsGrpcServerUnaryInterceptor(constructor any) fx.Option
- func GetReturnType(target any) string
- func GetType(target any) string
- func NewFxGrpcDefaultTestBufconnConnectionFactory(p FxGrpcTestBufconnConnectionFactoryParam) *grpcservertest.DefaultTestBufconnConnectionFactory
- func NewFxGrpcServer(p FxGrpcServerParam) (*grpc.Server, error)
- func NewFxGrpcTestBufconnListener(p FxGrpcTestBufconnListenerParam) *bufconn.Listener
- func Sanitize(str string) string
- func Split(str string) []string
- type FxGrpcServerModuleInfo
- type FxGrpcServerParam
- type FxGrpcServiceRegistryParam
- type FxGrpcTestBufconnConnectionFactoryParam
- type FxGrpcTestBufconnListenerParam
- type GrpcServerRegistry
- func (r *GrpcServerRegistry) ResolveGrpcServerOptions() []grpc.ServerOption
- func (r *GrpcServerRegistry) ResolveGrpcServerServices() ([]*ResolvedGrpcServerService, error)
- func (r *GrpcServerRegistry) ResolveGrpcServerStreamInterceptors() []GrpcServerStreamInterceptor
- func (r *GrpcServerRegistry) ResolveGrpcServerUnaryInterceptors() []GrpcServerUnaryInterceptor
- type GrpcServerServiceDefinition
- type GrpcServerStreamInterceptor
- type GrpcServerUnaryInterceptor
- type ResolvedGrpcServerService
Constants ¶
const ( ModuleName = "grpcserver" DefaultAddress = ":50051" DefaultBufconnSize = 1024 * 1024 )
Variables ¶
var FxGrpcServerModule = fx.Module( ModuleName, fx.Provide( grpcserver.NewDefaultGrpcServerFactory, NewFxGrpcTestBufconnListener, NewFxGrpcServerRegistry, NewFxGrpcServer, fx.Annotate( NewFxGrpcDefaultTestBufconnConnectionFactory, fx.As(new(grpcservertest.TestBufconnConnectionFactory)), ), fx.Annotate( NewFxGrpcServerModuleInfo, fx.As(new(interface{})), fx.ResultTags(`group:"core-module-infos"`), ), ), )
FxGrpcServerModule is the Fx grpcserver module.
Functions ¶
func AsGrpcServerOptions ¶
func AsGrpcServerOptions(options ...grpc.ServerOption) fx.Option
AsGrpcServerOptions registers a list of grpc server options into Fx.
func AsGrpcServerService ¶
func AsGrpcServerService(constructor any, description *grpc.ServiceDesc) fx.Option
AsGrpcServerService registers a grpc server service into Fx.
func AsGrpcServerStreamInterceptor ¶
AsGrpcServerStreamInterceptor registers a grpc server stream interceptor into Fx.
func AsGrpcServerUnaryInterceptor ¶
AsGrpcServerUnaryInterceptor registers a grpc server unary interceptor into Fx.
func GetReturnType ¶
GetReturnType returns the return type of a target.
func NewFxGrpcDefaultTestBufconnConnectionFactory ¶ added in v1.3.0
func NewFxGrpcDefaultTestBufconnConnectionFactory(p FxGrpcTestBufconnConnectionFactoryParam) *grpcservertest.DefaultTestBufconnConnectionFactory
NewFxGrpcDefaultTestBufconnConnectionFactory returns a new grpcservertest.DefaultTestBufconnConnectionFactory.
func NewFxGrpcServer ¶
func NewFxGrpcServer(p FxGrpcServerParam) (*grpc.Server, error)
NewFxGrpcServer returns a new grpc.Server.
func NewFxGrpcTestBufconnListener ¶ added in v1.3.0
func NewFxGrpcTestBufconnListener(p FxGrpcTestBufconnListenerParam) *bufconn.Listener
NewFxGrpcTestBufconnListener returns a new bufconn.Listener.
Types ¶
type FxGrpcServerModuleInfo ¶
type FxGrpcServerModuleInfo struct { Address string Services map[string]grpc.ServiceInfo }
FxGrpcServerModuleInfo is a module info collector for fxcore.
func NewFxGrpcServerModuleInfo ¶
func NewFxGrpcServerModuleInfo(grpcServer *grpc.Server, cfg *config.Config) *FxGrpcServerModuleInfo
NewFxGrpcServerModuleInfo returns a new FxGrpcServerModuleInfo.
func (*FxGrpcServerModuleInfo) Data ¶
func (i *FxGrpcServerModuleInfo) Data() map[string]interface{}
Data return the data of the module info.
func (*FxGrpcServerModuleInfo) Name ¶
func (i *FxGrpcServerModuleInfo) Name() string
Name return the name of the module info.
type FxGrpcServerParam ¶
type FxGrpcServerParam struct { fx.In LifeCycle fx.Lifecycle Factory grpcserver.GrpcServerFactory Generator uuid.UuidGenerator Listener *bufconn.Listener Registry *GrpcServerRegistry Config *config.Config Logger *log.Logger Checker *healthcheck.Checker TracerProvider trace.TracerProvider MetricsRegistry *prometheus.Registry }
FxGrpcServerParam allows injection of the required dependencies in [NewFxGrpcBufconnListener].
type FxGrpcServiceRegistryParam ¶
type FxGrpcServiceRegistryParam struct { fx.In Options []grpc.ServerOption `group:"grpc-server-options"` UnaryInterceptors []GrpcServerUnaryInterceptor `group:"grpc-server-unary-interceptors"` StreamInterceptors []GrpcServerStreamInterceptor `group:"grpc-server-stream-interceptors"` Services []any `group:"grpc-server-services"` Definitions []GrpcServerServiceDefinition `group:"grpc-server-service-definitions"` }
FxGrpcServiceRegistryParam allows injection of the required dependencies in NewFxGrpcServerRegistry.
type FxGrpcTestBufconnConnectionFactoryParam ¶ added in v1.3.0
FxGrpcTestBufconnConnectionFactoryParam allows injection of the required dependencies in NewFxGrpcDefaultTestBufconnConnectionFactory.
type FxGrpcTestBufconnListenerParam ¶ added in v1.3.0
FxGrpcTestBufconnListenerParam allows injection of the required dependencies in NewFxGrpcTestBufconnListener.
type GrpcServerRegistry ¶
type GrpcServerRegistry struct {
// contains filtered or unexported fields
}
GrpcServerRegistry is the registry collecting grpc server options, interceptors, services and their definitions.
func NewFxGrpcServerRegistry ¶
func NewFxGrpcServerRegistry(p FxGrpcServiceRegistryParam) *GrpcServerRegistry
NewFxGrpcServerRegistry returns as new GrpcServerRegistry.
func (*GrpcServerRegistry) ResolveGrpcServerOptions ¶
func (r *GrpcServerRegistry) ResolveGrpcServerOptions() []grpc.ServerOption
ResolveGrpcServerOptions resolves a list of grpc server options.
func (*GrpcServerRegistry) ResolveGrpcServerServices ¶
func (r *GrpcServerRegistry) ResolveGrpcServerServices() ([]*ResolvedGrpcServerService, error)
ResolveGrpcServerServices resolves a list of ResolvedGrpcServerService from their definitions.
func (*GrpcServerRegistry) ResolveGrpcServerStreamInterceptors ¶
func (r *GrpcServerRegistry) ResolveGrpcServerStreamInterceptors() []GrpcServerStreamInterceptor
ResolveGrpcServerStreamInterceptors resolves a list of grpc server stream interceptors.
func (*GrpcServerRegistry) ResolveGrpcServerUnaryInterceptors ¶
func (r *GrpcServerRegistry) ResolveGrpcServerUnaryInterceptors() []GrpcServerUnaryInterceptor
ResolveGrpcServerUnaryInterceptors resolves a list of grpc server unary interceptors.
type GrpcServerServiceDefinition ¶
type GrpcServerServiceDefinition interface { ReturnType() string Description() *grpc.ServiceDesc }
GrpcServerServiceDefinition is the interface for grpc server services definitions.
func NewGrpcServiceDefinition ¶
func NewGrpcServiceDefinition(returnType string, description *grpc.ServiceDesc) GrpcServerServiceDefinition
NewGrpcServiceDefinition returns a new GrpcServerServiceDefinition instance.
type GrpcServerStreamInterceptor ¶
type GrpcServerStreamInterceptor interface {
HandleStream() grpc.StreamServerInterceptor
}
GrpcServerStreamInterceptor is the interface for grpc server stream interceptors.
type GrpcServerUnaryInterceptor ¶
type GrpcServerUnaryInterceptor interface {
HandleUnary() grpc.UnaryServerInterceptor
}
GrpcServerUnaryInterceptor is the interface for grpc server unary interceptors.
type ResolvedGrpcServerService ¶
type ResolvedGrpcServerService struct {
// contains filtered or unexported fields
}
ResolvedGrpcServerService is an interface for the resolved grpc server services.
func NewResolvedGrpcService ¶
func NewResolvedGrpcService(implementation any, description *grpc.ServiceDesc) *ResolvedGrpcServerService
NewResolvedGrpcService returns a new ResolvedGrpcServerService.
func (*ResolvedGrpcServerService) Description ¶
func (r *ResolvedGrpcServerService) Description() *grpc.ServiceDesc
Description return the resolved grpc server service description.
func (*ResolvedGrpcServerService) Implementation ¶
func (r *ResolvedGrpcServerService) Implementation() any
Implementation return the resolved grpc server service implementation.