rpc

package
v0.0.0-...-e43fadc Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRootPrivileges = errors.New("You must have root user privileges. Possibly using 'sudo' command should help")
View Source
var ErrUnsupportedSystem = errors.New("Unsupported system")

Functions

func SetCircuitBreaker

func SetCircuitBreaker(set ISetCircuitBreaker, cnf conf.IServerConf) (enable bool, err error)

SetCircuitBreaker 设置熔断配置

func SetHeaders

func SetHeaders(set ISetHeaderHandler, cnf conf.IServerConf) (enable bool, err error)

SetHeaders 设置header

func SetHosts

func SetHosts(set ISetHosts, cnf conf.IServerConf) (enable bool, err error)

SetHosts 设置hosts

func SetJWT

func SetJWT(set ISetJwtAuth, cnf conf.IServerConf) (enable bool, err error)

SetJWT 设置jwt

func SetMetric

func SetMetric(set ISetMetric, cnf conf.IServerConf) (enable bool, err error)

SetMetric 设置metric

func SetRouters

func SetRouters(engine servers.IRegistryEngine, cnf conf.IServerConf, set ISetRouterHandler, ext map[string]interface{}) (enable bool, err error)

func SetStatic

func SetStatic(set ISetStatic, cnf conf.IServerConf) (enable bool, err error)

SetStatic 设置static

Types

type Handler

type Handler interface {
	Handle(*dispatcher.Context)
}

type ISetCircuitBreaker

type ISetCircuitBreaker interface {
	CloseCircuitBreaker() error
	SetCircuitBreaker(*conf.CircuitBreaker) error
}

ISetCircuitBreaker 设置CircuitBreaker

type ISetHeaderHandler

type ISetHeaderHandler interface {
	SetHeader(conf.Headers) error
}

ISetHeaderHandler 设置header

type ISetHosts

type ISetHosts interface {
	SetHosts(conf.Hosts) error
}

ISetHosts 设置hosts

type ISetJwtAuth

type ISetJwtAuth interface {
	SetJWT(*conf.Auth) error
}

ISetJwtAuth 设置jwt

type ISetMetric

type ISetMetric interface {
	SetMetric(*conf.Metric) error
}

type ISetRouterHandler

type ISetRouterHandler interface {
	SetRouters([]*conf.Router) error
}

ISetRouterHandler 设置路由列表

type ISetStatic

type ISetStatic interface {
	SetStatic(static *conf.Static) error
}

type Option

type Option func(*option)

Option 配置选项

func WithIP

func WithIP(ip string) Option

WithIP 设置ip地址

func WithLogger

func WithLogger(logger *logger.Logger) Option

WithLogger 设置日志记录组件

func WithMetric

func WithMetric(host string, dataBase string, userName string, password string, cron string) Option

WithMetric 设置基于influxdb的系统监控组件

func WithName

func WithName(platName string, systemName string, clusterName string, serverType string) Option

func WithShowTrace

func WithShowTrace(b bool) Option

WithShowTrace 显示跟踪信息

func WithTLS

func WithTLS(tls []string) Option

WithTLS 设置TLS证书(pem,key)

type Processor

type Processor struct {
	*dispatcher.Dispatcher
}

func NewProcessor

func NewProcessor() *Processor

func (*Processor) Request

func (r *Processor) Request(context context.Context, request *pb.RequestContext) (p *pb.ResponseContext, err error)

type Request

type Request struct {
	*pb.RequestContext
	// contains filtered or unexported fields
}

func (*Request) GetForm

func (r *Request) GetForm() map[string]interface{}

func (*Request) GetHeader

func (r *Request) GetHeader() map[string]string

type Routers

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

func GetRouters

func GetRouters() *Routers

func (*Routers) Get

func (r *Routers) Get() []*conf.Router

func (*Routers) Route

func (r *Routers) Route(method string, name string, f servers.IRegistryEngine)

type RpcResponsiveServer

type RpcResponsiveServer struct {
	*logger.Logger
	// contains filtered or unexported fields
}

RpcResponsiveServer rpc 响应式服务器

func NewRpcResponsiveServer

func NewRpcResponsiveServer(registryAddr string, cnf conf.IServerConf, logger *logger.Logger) (h *RpcResponsiveServer, err error)

NewRpcResponsiveServer 创建rpc服务器

func (*RpcResponsiveServer) GetAddress

func (w *RpcResponsiveServer) GetAddress() string

GetAddress 获取服务器地址

func (*RpcResponsiveServer) GetServices

func (w *RpcResponsiveServer) GetServices() map[string][]string

GetServices 获取服务列表

func (*RpcResponsiveServer) GetStatus

func (w *RpcResponsiveServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*RpcResponsiveServer) NeedRestart

func (w *RpcResponsiveServer) NeedRestart(cnf conf.IServerConf) (bool, error)

NeedRestart 检查配置判断是否需要重启服务器

func (*RpcResponsiveServer) Notify

func (w *RpcResponsiveServer) Notify(nConf conf.IServerConf) error

Notify 服务器配置变更通知

func (*RpcResponsiveServer) Restart

func (w *RpcResponsiveServer) Restart(cnf conf.IServerConf) (err error)

Restart 重启服务器

func (*RpcResponsiveServer) Restarted

func (w *RpcResponsiveServer) Restarted() bool

Restarted 服务器是否已重启

func (*RpcResponsiveServer) SetConf

func (w *RpcResponsiveServer) SetConf(restart bool, conf conf.IServerConf) (err error)

SetConf 设置配置参数

func (*RpcResponsiveServer) SetPb

func (w *RpcResponsiveServer) SetPb(f func(component.IContainer, *grpc.Server))

func (*RpcResponsiveServer) Shutdown

func (w *RpcResponsiveServer) Shutdown()

Shutdown 关闭服务器

func (*RpcResponsiveServer) Start

func (w *RpcResponsiveServer) Start() (err error)

Start 启用服务

type RpcServer

type RpcServer struct {
	*Processor
	// contains filtered or unexported fields
}

RpcServer rpc服务器

func NewRpcServer

func NewRpcServer(name string, address string, routers []*conf.Router, opts ...Option) (t *RpcServer, err error)

NewRpcServer 创建rpc服务器

func (*RpcServer) GetAddress

func (s *RpcServer) GetAddress(h ...string) string

GetAddress 获取当前服务地址

func (*RpcServer) GetStatus

func (s *RpcServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*RpcServer) Run

func (s *RpcServer) Run() error

Run the http server

func (*RpcServer) SetHeader

func (s *RpcServer) SetHeader(headers conf.Headers) error

SetHeader 设置http头

func (*RpcServer) SetHosts

func (s *RpcServer) SetHosts(hosts conf.Hosts) error

SetHosts 设置组件的host name

func (*RpcServer) SetJWT

func (s *RpcServer) SetJWT(auth *conf.Auth) error

SetJWT Server

func (*RpcServer) SetMetric

func (s *RpcServer) SetMetric(metric *conf.Metric) error

SetMetric 重置metric

func (*RpcServer) SetPb

func (s *RpcServer) SetPb(f func(component.IContainer, *grpc.Server))

func (*RpcServer) SetRouters

func (s *RpcServer) SetRouters(routers []*conf.Router) (err error)

SetRouters 设置路由配置

func (*RpcServer) SetTrace

func (s *RpcServer) SetTrace(b bool)

SetTrace 显示跟踪信息

func (*RpcServer) Shutdown

func (s *RpcServer) Shutdown(timeout time.Duration)

Shutdown 关闭服务器

func (*RpcServer) StopMetric

func (s *RpcServer) StopMetric() error

StopMetric stop metric

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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