egrpc

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 38 Imported by: 14

Documentation

Index

Constants

View Source
const PackageName = "server.egrpc"

PackageName 包名

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	*grpc.Server
	// contains filtered or unexported fields
}

Component ...

func (*Component) Address

func (c *Component) Address() string

Address 服务地址

func (*Component) GracefulStop

func (c *Component) GracefulStop(ctx context.Context) error

GracefulStop implements server.Component interface it will stop echo server gracefully

func (*Component) Info

func (c *Component) Info() *server.ServiceInfo

Info returns server info, used by governor and consumer balancer

func (*Component) Init

func (c *Component) Init() error

Init 初始化

func (*Component) Listener added in v0.6.11

func (c *Component) Listener() net.Listener

Listener listener信息

func (*Component) Name

func (c *Component) Name() string

Name 配置名称

func (*Component) PackageName

func (c *Component) PackageName() string

PackageName 包名

func (*Component) Start

func (c *Component) Start() error

Start implements server.Component interface.

func (*Component) Stop

func (c *Component) Stop() error

Stop implements server.Component interface it will terminate echo server immediately

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          // 是否开启,记录请求数据
	EnableAccessInterceptorReq bool          // 是否开启记录请求参数,默认不开启
	EnableAccessInterceptorRes bool          // 是否开启记录响应参数,默认不开启
	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

func (Config) Address

func (config Config) Address() string

Address ...

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container 容器

func DefaultContainer

func DefaultContainer() *Container

DefaultContainer 默认容器

func Load

func Load(key string) *Container

Load 加载配置key

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

Build ...

type Option

type Option func(c *Container)

Option 可选项

func WithLogger added in v0.7.0

func WithLogger(logger *elog.Component) Option

WithLogger inject logger

func WithNetwork added in v0.6.12

func WithNetwork(network string) Option

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 recommend 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

Jump to

Keyboard shortcuts

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