Documentation ¶
Index ¶
- Constants
- Variables
- type BaseHttpService
- type GinEngine
- func (ge *GinEngine) Close()
- func (ge *GinEngine) GetGrpcServer() *grpc.Server
- func (ge *GinEngine) GetHttpRegisteredGroup(path string) (*gin.RouterGroup, error)
- func (ge *GinEngine) GrpcServiceRegistry(services ...GrpcRegisteredServiceItem)
- func (ge *GinEngine) HttpMiddlewareRegistry(middleware ...gin.HandlerFunc)
- func (ge *GinEngine) HttpRouteGroupRegistry(path string, baseGroup *gin.RouterGroup)
- func (ge *GinEngine) HttpServiceRegistry(services ...httpServiceInterface)
- func (ge *GinEngine) IsReleaseMode() bool
- func (ge *GinEngine) RunAndService()
- type GinEngineConf
- type GinEngineFeatureOpts
- type GinEngineMiddlewareOpts
- type GinEngineNoMatchHandlers
- type GinHttpProfService
- type GrpcRegisteredServiceItem
- type HttpServerConf
Constants ¶
View Source
const ( ConstPromMetricUrlPath = "/metrics" ConstHttpHealthCheckUrlPath = "/healthcheck" ConstRootUrlPath = "/" ConstSwaggerUrlPath = "/docs/*any" )
Variables ¶
View Source
var RouteNoRegisteredError = errors.New("router group not registered")
Functions ¶
This section is empty.
Types ¶
type BaseHttpService ¶
type BaseHttpService struct {
// contains filtered or unexported fields
}
func NewBaseHttpService ¶
func NewBaseHttpService(f func(*gin.RouterGroup)) *BaseHttpService
func (*BaseHttpService) RoutesRegistry ¶
func (bhs *BaseHttpService) RoutesRegistry(ge *GinEngine)
type GinEngine ¶
type GinEngine struct { RootRouteGroup *gin.RouterGroup // contains filtered or unexported fields }
func NewGinEngine ¶
func NewGinEngine(name string, engineConf *GinEngineConf, httpConf *HttpServerConf, middlewareOpts *GinEngineMiddlewareOpts) *GinEngine
NewGinEngine keepalive.EnforcementPolicy: MinTime:如果客户端两次 ping 的间隔小于此值,则关闭连接 PermitWithoutStream: 即使没有 active stream, 也允许 ping
keepalive.ServerParameters: MaxConnectionIdle:如果一个 client 空闲超过该值, 发送一个 GOAWAY, 为了防止同一时间发送大量 GOAWAY, 会在此时间间隔上下浮动 10%, 例如设置为15s,即 15+1.5 或者 15-1.5 MaxConnectionAge:如果任意连接存活时间超过该值, 发送一个 GOAWAY MaxConnectionAgeGrace:在强制关闭连接之间, 允许有该值的时间完成 pending 的 rpc 请求 Time: 如果一个 client 空闲超过该值, 则发送一个 ping 请求 Timeout: 如果 ping 请求该时间段内未收到回复, 则认为该连接已断开
func (*GinEngine) GetGrpcServer ¶ added in v1.1.0
func (*GinEngine) GetHttpRegisteredGroup ¶ added in v1.1.0
func (ge *GinEngine) GetHttpRegisteredGroup(path string) (*gin.RouterGroup, error)
GetHttpRegisteredGroup 获得已经注册的路由组
func (*GinEngine) GrpcServiceRegistry ¶ added in v1.1.0
func (ge *GinEngine) GrpcServiceRegistry(services ...GrpcRegisteredServiceItem)
GrpcServiceRegistry 注册服务到 GinEngine
func (*GinEngine) HttpMiddlewareRegistry ¶ added in v1.1.0
func (ge *GinEngine) HttpMiddlewareRegistry(middleware ...gin.HandlerFunc)
func (*GinEngine) HttpRouteGroupRegistry ¶ added in v1.1.0
func (ge *GinEngine) HttpRouteGroupRegistry(path string, baseGroup *gin.RouterGroup)
HttpRouteGroupRegistry 注册一个路由组
func (*GinEngine) HttpServiceRegistry ¶ added in v1.1.0
func (ge *GinEngine) HttpServiceRegistry(services ...httpServiceInterface)
HttpServiceRegistry 注册服务到 GinEngine
func (*GinEngine) IsReleaseMode ¶
func (*GinEngine) RunAndService ¶
func (ge *GinEngine) RunAndService()
type GinEngineConf ¶
type GinEngineConf struct { FeatureOpts GinEngineFeatureOpts NoMatchHandlers GinEngineNoMatchHandlers }
func NewDefaultGinEngineConf ¶ added in v1.1.1
func NewDefaultGinEngineConf() *GinEngineConf
func NewOnlyHttpGinEngineConf ¶ added in v1.1.1
func NewOnlyHttpGinEngineConf() *GinEngineConf
func NewOnlyMetricsGinEngineConf ¶ added in v1.1.1
func NewOnlyMetricsGinEngineConf() *GinEngineConf
type GinEngineFeatureOpts ¶
type GinEngineFeatureOpts struct { EnableGinRedirectTrailingSlash bool // 内部 301 路径跳转,如果当前路径的处理函数不存在,但是路径+'/'的处理函数存在,则允许进行重定向 EnableGinRedirectFixedPath bool // 允许修复当前请求路径,如/FOO和/..//Foo会被修复为/foo,并进行重定向,默认为 false。 EnableHttpHealthCheck bool // 健康检查 EnablePrometheusMetrics bool // 记录 Prometheus 数据 EnablePrometheusRoute bool // 能够访问 Prometheus 数据 EnableSwagger bool // Swagger EnableHttpPProf bool // running time debug EnableGrpc bool // 启动 grpc over http }
type GinEngineMiddlewareOpts ¶ added in v1.1.0
type GinEngineMiddlewareOpts struct { HttpSvrMiddleware []gin.HandlerFunc GrpcSvrMiddleware struct { StreamInterceptors []grpc.StreamServerInterceptor UnaryInterceptors []grpc.UnaryServerInterceptor } }
type GinEngineNoMatchHandlers ¶
type GinEngineNoMatchHandlers = struct { NoRouteHandlers []gin.HandlerFunc NoMethodHandlers []gin.HandlerFunc }
type GinHttpProfService ¶
type GinHttpProfService struct { }
func NewGinHttpProfService ¶
func NewGinHttpProfService() *GinHttpProfService
func (GinHttpProfService) RoutesRegistry ¶
func (gp GinHttpProfService) RoutesRegistry(ge *GinEngine)
type GrpcRegisteredServiceItem ¶ added in v1.1.0
type GrpcRegisteredServiceItem struct { ServiceDesc *grpc.ServiceDesc ServiceServer interface{} }
type HttpServerConf ¶
type HttpServerConf struct { Address string `json:"address" yaml:"address"` Port uint16 `json:"port" yaml:"port"` HttpReadTimeout uint32 `json:"httpReadTimeout,omitempty" yaml:"httpReadTimeout,omitempty"` HttpWriteTimeout uint32 `json:"httpWriteTimeout,omitempty" yaml:"httpWriteTimeout,omitempty"` HttpReadHeaderTimeout uint32 `json:"httpReadHeaderTimeout,omitempty" yaml:"httpReadHeaderTimeout,omitempty"` GrpcClientPingMinIntervalTime uint32 `json:"grpcClientPingMinIntervalTime,omitempty" yaml:"grpcClientPingMinIntervalTime,omitempty"` GrpcClientIdleTimeout uint32 `json:"grpcClientIdleTimeout,omitempty" yaml:"grpcClientIdleTimeout,omitempty"` GrpcConnAgeGraceTimeout uint32 `json:"grpcConnAgeGraceTimeout,omitempty" yaml:"grpcConnAgeGraceTimeout,omitempty"` }
Click to show internal directories.
Click to hide internal directories.