xgrpc

package
v3.2.27 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamInterceptorChain

func StreamInterceptorChain(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor

StreamInterceptorChain returns stream interceptors chain.

func UnaryInterceptorChain

func UnaryInterceptorChain(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor

UnaryInterceptorChain returns interceptors chain.

Types

type Config

type Config struct {
	Name       string `json:"name"`
	Host       string `json:"host"`
	Port       int    `json:"port"`
	Deployment string `json:"deployment"`
	// Network network type, tcp4 by default
	Network string `json:"network" toml:"network"`
	// DisableTrace  Trace Interceptor, false by default
	DisableTrace bool
	// DisableMetric disable Metric Interceptor, false by default
	DisableMetric bool
	// SlowQueryThresholdInMilli, request will be colored if cost over this threshold value
	SlowQueryThresholdInMilli int64
	// ServiceAddress service address in registry info, default to 'Host:Port'
	ServiceAddress string
	// EnableTLS
	EnableTLS bool
	// CaFile
	CaFile string
	// CertFile
	CertFile string
	// PrivateFile
	PrivateFile string
	Labels      map[string]string `json:"labels"`
	// contains filtered or unexported fields
}

Config ...

func New

func New() *Config

New ...

func (Config) Address

func (config Config) Address() string

Address ...

func (*Config) Build

func (config *Config) Build() (*Server, error)

Build ...

func (*Config) MustBuild

func (config *Config) MustBuild() *Server

MustBuild ...

func (*Config) WithServerOption

func (config *Config) WithServerOption(options ...grpc.ServerOption) *Config

WithServerOption inject server option to grpc server User should not inject interceptor option, which is recommend by WithStreamInterceptor and WithUnaryInterceptor

func (*Config) WithStreamInterceptor

func (config *Config) WithStreamInterceptor(intes ...grpc.StreamServerInterceptor) *Config

WithStreamInterceptor inject stream interceptors to server option

func (*Config) WithUnaryInterceptor

func (config *Config) WithUnaryInterceptor(intes ...grpc.UnaryServerInterceptor) *Config

WithUnaryInterceptor inject unary interceptors to server option

type Server

type Server struct {
	*grpc.Server

	*Config
	// contains filtered or unexported fields
}

Server ...

func (*Server) GracefulStop

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

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

func (*Server) Health added in v3.2.17

func (s *Server) Health() bool

Health ...

func (*Server) Info

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

Info returns server info, used by governor and consumer balancer

func (*Server) Serve

func (s *Server) Serve() error

Serve implements server.Serve interface.

func (*Server) Stop

func (s *Server) Stop() error

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

Jump to

Keyboard shortcuts

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