Documentation ¶
Index ¶
- Constants
- type Component
- func (c *Component) GracefulStop(ctx context.Context) error
- func (c *Component) Info() *server.ServiceInfo
- func (c *Component) Init() error
- func (c *Component) Name() string
- func (c *Component) PackageName() string
- func (c *Component) RegisterRouteComment(method, path, comment string)
- func (c *Component) Start() error
- func (c *Component) Stop() error
- func (c *Component) Upgrade(ws *WebSocket) gin.IRoutes
- type Config
- type Container
- type Option
- type WebSocket
- type WebSocketConn
- type WebSocketFunc
- type WebSocketOption
Constants ¶
View Source
const PackageName = "server.egin"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
Component ...
func (*Component) GracefulStop ¶
GracefulStop implements server.Component interface it will stop gin server gracefully
func (*Component) Info ¶
func (c *Component) Info() *server.ServiceInfo
Info returns server info, used by governor and consumer balancer
func (*Component) PackageName ¶
func (*Component) RegisterRouteComment ¶
注册路由注释
type Config ¶
type Config struct { Host string // IP地址,默认127.0.0.1 Port int // PORT端口,默认9001 Mode string // gin的模式,默认是release模式 EnableMetricInterceptor bool // 是否开启监控,默认开启 EnableTraceInterceptor bool // 是否开启链路追踪,默认开启 EnableLocalMainIP bool // 自动获取ip地址 SlowLogThreshold time.Duration // 服务慢日志,默认500ms }
Config HTTP config
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func DefaultContainer ¶
func DefaultContainer() *Container
type WebSocket ¶
type WebSocket struct { Pattern string Handler WebSocketFunc *websocket.Upgrader Header http.Header }
WebSocket ..
func WebSocketOptions ¶
func WebSocketOptions(pattern string, handler WebSocketFunc, opts ...WebSocketOption) *WebSocket
WebSocketOptions ..
type WebSocketConn ¶
type WebSocketConn interface { Subprotocol() string Close() error LocalAddr() net.Addr RemoteAddr() net.Addr WriteControl(messageType int, data []byte, deadline time.Time) error NextWriter(messageType int) (io.WriteCloser, error) WritePreparedMessage(pm *websocket.PreparedMessage) error WriteMessage(messageType int, data []byte) error SetWriteDeadline(t time.Time) error NextReader() (messageType int, r io.Reader, err error) ReadMessage() (messageType int, p []byte, err error) SetReadDeadline(t time.Time) error SetReadLimit(limit int64) CloseHandler() func(code int, text string) error SetCloseHandler(h func(code int, text string) error) PingHandler() func(appData string) error SetPingHandler(h func(appData string) error) PongHandler() func(appData string) error SetPongHandler(h func(appData string) error) UnderlyingConn() net.Conn EnableWriteCompression(enable bool) SetCompressionLevel(level int) error }
WebSocketConn websocket conn, see websocket.Conn
Click to show internal directories.
Click to hide internal directories.