Documentation ¶
Index ¶
- Constants
- func CtxStoreSet(ctx context.Context, k string, v any)
- type Component
- func (c *Component) Address() string
- func (c *Component) GracefulStop(ctx context.Context) error
- func (c *Component) Health() bool
- func (c *Component) Info() *server.ServiceInfo
- func (c *Component) Init() error
- func (c *Component) Invoker(fns ...func() error)
- func (c *Component) Listener() net.Listener
- func (c *Component) Name() string
- func (c *Component) PackageName() string
- func (c *Component) Prepare() error
- func (c *Component) Start() error
- func (c *Component) Stop() error
- type Config
- type Container
- type Option
- func WithLogger(logger *elog.Component) Option
- func WithNetwork(network string) Option
- func WithServerOption(options ...grpc.ServerOption) Option
- func WithStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) Option
- func WithUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) Option
- func WithUnaryServerBlockFallback(...) Option
- func WithUnaryServerResourceExtractor(fn func(context.Context, interface{}, *grpc.UnaryServerInfo) string) Option
Constants ¶
const PackageName = "server.egrpc"
PackageName 包名
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Component ¶
Component ...
func (*Component) GracefulStop ¶
GracefulStop implements server.Component interface it will stop echo server gracefully
func (*Component) Health ¶ added in v1.1.10
Health implements server.Component interface. Experimental
func (*Component) Info ¶
func (c *Component) Info() *server.ServiceInfo
Info returns server info, used by governor and consumer balancer
func (*Component) Invoker ¶ added in v1.1.10
Invoker returns server info, used by governor and consumer balancer
type Config ¶
type Config struct { Host string // IP地址,默认0.0.0.0 Port int // Port端口,默认9002 Deployment string // 部署区域 Network string // 网络类型,默认tcp4 EnableMetricInterceptor bool // 是否开启监控,默认开启 EnableTraceInterceptor bool // 是否开启链路追踪,默认开启 EnableOfficialGrpcLog bool // 是否开启官方grpc日志,默认关闭 EnableSkipHealthLog bool // 是否屏蔽探活日志,默认开启 SlowLogThreshold time.Duration // 服务慢日志,默认500ms EnableAccessInterceptor bool // 是否开启,记录请求数据 EnableSentinel bool // 是否开启限流,默认不开启 EnableAccessInterceptorReq bool // 是否开启记录请求参数,默认不开启 AccessInterceptorReqMaxLength int // 默认4K EnableAccessInterceptorRes bool // 是否开启记录响应参数,默认不开启 AccessInterceptorResMaxLength int // 默认4K EnableLocalMainIP bool // 自动获取ip地址 // contains filtered or unexported fields }
Config ...
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig represents default config User should construct config base on DefaultConfig
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container defines a component instance.
func DefaultContainer ¶
func DefaultContainer() *Container
DefaultContainer returns an default container.
type Option ¶
type Option func(c *Container)
Option overrides a Container's default configuration.
func WithLogger ¶ added in v0.7.0
WithLogger inject logger
func WithNetwork ¶ added in v0.6.12
WithNetwork inject network
func WithServerOption ¶
func WithServerOption(options ...grpc.ServerOption) Option
WithServerOption inject server option to grpc server User should not inject interceptor option, which is recommended by WithStreamInterceptor and WithUnaryInterceptor
func WithStreamInterceptor ¶
func WithStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) Option
WithStreamInterceptor inject stream interceptors to server option
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) Option
WithUnaryInterceptor inject unary interceptors to server option
func WithUnaryServerBlockFallback ¶ added in v1.1.10
func WithUnaryServerBlockFallback(fn func(context.Context, interface{}, *grpc.UnaryServerInfo, *base.BlockError) (interface{}, error)) Option
WithUnaryServerBlockFallback sets the block fallback handler of unary server request.
func WithUnaryServerResourceExtractor ¶ added in v1.1.10
func WithUnaryServerResourceExtractor(fn func(context.Context, interface{}, *grpc.UnaryServerInfo) string) Option
WithUnaryServerResourceExtractor sets the resource extractor of unary server request.