Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( InvalidGrpcServer = errors.New("invalid grpc server") InvalidGrpcConf = errors.New("invalid grpc config") )
View Source
var ( InvalidHttpConf = errors.New("invalid http config") InvalidHttpEngine = errors.New("invalid http engine") )
Functions ¶
func GraceGrpcServer ¶ added in v1.2.2
GraceGrpcServer 优雅启动grpc服务.
func GraceHttpServer ¶ added in v1.2.2
Types ¶
type GraceGrpc ¶ added in v1.3.2
type GraceGrpc struct { // Addr grpc地址, eg: ":7777" Addr string Server *grpc.Server // RegisterReflect 启动grpc反射 RegisterReflect bool // EnableGateway 启动grpc gateway EnableGateway bool // GatewayAddr gateway的地址 GatewayAddr string // HttpHandlers http处理器 HttpHandlers []HttpHandler // GatewayWaitTime gateway关闭时, 处理gateway请求时间 GatewayWaitTime time.Duration // OnHookFunc 勾子函数 OnHookFunc }
GraceGrpc grpc启动配置.
type HookHandler ¶ added in v1.2.2
type HookHandler func() error
type HttpHandler ¶ added in v1.3.2
type OnHookFunc ¶ added in v1.2.2
type OnHookFunc struct { // StartUp 服务启动前执行函数 StartUp []HookHandler // ShutDown 停止服务执行函数 ShutDown []HookHandler }
OnHookFunc 勾子结构体.
func (OnHookFunc) ExecuteShutDown ¶ added in v1.3.2
func (h OnHookFunc) ExecuteShutDown() error
ExecuteShutDown 执行结束后操作.
func (OnHookFunc) ExecuteStartUp ¶ added in v1.3.2
func (h OnHookFunc) ExecuteStartUp() error
ExecuteStartUp 执行启动前操作.
type Setting ¶ added in v1.3.2
type Setting struct { Host string `json:"host" yaml:"host"` // 地址 Port int `json:"port" yaml:"port"` // 端口, 默认是9000 Language string `json:"language" yaml:"language"` // 校验错误返回的语言 ShutDownTimeout int `json:"shutDownTimeout" yaml:"shutDownTimeout"` // 优雅重启, 接收到相关信号后, 处理请求的最长时间, 单位: 秒, 默认3s Application string `json:"application" yaml:"application"` // 应用名 Debug bool `json:"debug" yaml:"debug"` // debug, 默认false Swagger bool `json:"swagger" yaml:"swagger"` // 是否启动swagger, 默认false LogConfig log.ZapLogReq `json:"log" yaml:"log"` // 日志配置 EnableRtPool bool `json:"enableRtPool" yaml:"enableRtPool"` // 启用协程池, 默认是false Routine routine.Routine `json:"routine" yaml:"routine"` // 协程池配置 Middlewares []gin.HandlerFunc // 中间件 OnHookFunc // server勾子函数 GrpcConf *GraceGrpc // grpc配置 }
Click to show internal directories.
Click to hide internal directories.