egrpc

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: MIT Imports: 26 Imported by: 14

Documentation

Index

Constants

View Source
const PackageName = "server.egrpc"

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

func (*Component) GracefulStop

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

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

func (*Component) Info

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

Info returns server info, used by governor and consumer balancer

func (*Component) Init

func (s *Component) Init() error

func (*Component) Name

func (s *Component) Name() string

func (*Component) PackageName

func (c *Component) PackageName() string

func (*Component) Start

func (s *Component) Start() error

Component implements server.Component interface.

func (*Component) Stop

func (s *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          // 是否开启链路追踪,默认开启
	SlowLogThreshold           time.Duration // 服务慢日志,默认500ms
	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
}

func DefaultContainer

func DefaultContainer() *Container

func Load

func Load(key string) *Container

func (*Container) Build

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

Build ...

type Option

type Option func(c *Container)

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