fxgrpcserver

package
v0.0.0-...-4ef61cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPort = 50051

Variables

Functions

func AsGrpcService

func AsGrpcService(description *grpc.ServiceDesc, constructor any) fx.Option

func CtxLogger

func CtxLogger(ctx context.Context) *fxlogger.Logger

func CtxTracer

func CtxTracer(ctx context.Context) trace.Tracer

func NewFxGrpcServer

func NewFxGrpcServer(p FxGrpcServerParam) (*grpc.Server, error)

func RegisterGrpcService

func RegisterGrpcService(grpcServiceRegistration *GrpcServiceRegistration) fx.Option

func StartFxGrpcServer

func StartFxGrpcServer() fx.Option

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) Watch

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 (*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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL