ws

package
v0.13.6-0...-d3ad96a Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 23 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 SetHosts

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

SetHosts 设置hosts

func SetHttpRouters

func SetHttpRouters(engine servers.IRegistryEngine, set ISetRouterHandler, cnf conf.IServerConf) (enable bool, err error)

SetHttpRouters 设置路由

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 SetStatic

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

SetStatic 设置static

Types

type Handler

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

type IServer

type IServer interface {
	Run() error
	Shutdown(timeout time.Duration)
	GetStatus() string
	GetAddress() string
	CloseCircuitBreaker() error
	SetCircuitBreaker(*conf.CircuitBreaker) error
	SetJWT(auth *conf.JWTAuth) error
	SetRouters(routers []*conf.Router) (err error)
	SetStatic(*conf.Static) error
	SetMetric(*conf.Metric) error
	StopMetric() error
}

type ISetCircuitBreaker

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

ISetCircuitBreaker 设置CircuitBreaker

type ISetHosts

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

ISetHosts 设置hosts

type ISetJwtAuth

type ISetJwtAuth interface {
	SetJWT(*conf.JWTAuth) 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 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 WithTimeout

func WithTimeout(readTimeout int, writeTimeout int, readHeaderTimeout int) Option

WithTimeout 设置服务器超时时长

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 interface{})

type WSServer

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

WSServer WSServer服务器

func NewWSServerServer

func NewWSServerServer(name string, addr string, routers []*conf.Router, opts ...Option) (t *WSServer, err error)

NewWSServerServer 创建WSServer服务器

func (*WSServer) CloseCircuitBreaker

func (s *WSServer) CloseCircuitBreaker() error

CloseCircuitBreaker 关闭熔断配置

func (*WSServer) GetAddress

func (s *WSServer) GetAddress() string

GetAddress 获取当前服务地址

func (*WSServer) GetStatus

func (s *WSServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*WSServer) Run

func (s *WSServer) Run() error

Run the http server

func (*WSServer) SetCircuitBreaker

func (s *WSServer) SetCircuitBreaker(c *conf.CircuitBreaker) error

SetCircuitBreaker 设置熔断配置

func (*WSServer) SetHosts

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

SetHosts 设置组件的host name

func (*WSServer) SetJWT

func (s *WSServer) SetJWT(auth *conf.JWTAuth) error

SetJWT Server

func (*WSServer) SetMetric

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

SetMetric 重置metric

func (*WSServer) SetRouters

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

SetRouters 设置路由配置

func (*WSServer) SetStatic

func (s *WSServer) SetStatic(static *conf.Static) error

SetStatic 设置静态文件路由

func (*WSServer) SetTrace

func (s *WSServer) SetTrace(b bool)

SetTrace 显示跟踪信息

func (*WSServer) Shutdown

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

Shutdown 关闭服务器

func (*WSServer) StopMetric

func (s *WSServer) StopMetric() error

StopMetric stop metric

type WSServerResponsiveServer

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

WSServerResponsiveServer WSServer 响应式服务器

func NewWSServerResponsiveServer

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

NewWSServerResponsiveServer 创建WSServer服务器

func (*WSServerResponsiveServer) GetAddress

func (w *WSServerResponsiveServer) GetAddress() string

GetAddress 获取服务器地址

func (*WSServerResponsiveServer) GetServices

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

GetServices 获取服务列表

func (*WSServerResponsiveServer) GetStatus

func (w *WSServerResponsiveServer) GetStatus() string

GetStatus 获取当前服务器状态

func (*WSServerResponsiveServer) NeedRestart

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

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

func (*WSServerResponsiveServer) Notify

Notify 服务器配置变更通知

func (*WSServerResponsiveServer) Restart

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

Restart 重启服务器

func (*WSServerResponsiveServer) Restarted

func (w *WSServerResponsiveServer) Restarted() bool

Restarted 服务器是否已重启

func (*WSServerResponsiveServer) SetConf

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

SetConf 设置配置参数

func (*WSServerResponsiveServer) Shutdown

func (w *WSServerResponsiveServer) Shutdown()

Shutdown 关闭服务器

func (*WSServerResponsiveServer) Start

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

Start 启用服务

Jump to

Keyboard shortcuts

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