egin

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 26 Imported by: 18

Documentation

Index

Constants

View Source
const PackageName = "server.egin"

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	*gin.Engine
	Server *http.Server
	// contains filtered or unexported fields
}

Component ...

func (*Component) GracefulStop

func (c *Component) GracefulStop(ctx context.Context) error

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) Init

func (c *Component) Init() error

func (*Component) Name

func (c *Component) Name() string

func (*Component) PackageName

func (c *Component) PackageName() string

func (*Component) RegisterRouteComment

func (c *Component) RegisterRouteComment(method, path, comment string)

注册路由注释

func (*Component) Start

func (c *Component) Start() error

Serve implements server.Component interface.

func (*Component) Stop

func (c *Component) Stop() error

Stop implements server.Component interface it will terminate gin server immediately

func (*Component) Upgrade

func (c *Component) Upgrade(ws *WebSocket) gin.IRoutes

Upgrade protocol to WebSocket

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

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

func (*Config) Address

func (config *Config) Address() string

Address ...

type Container

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

func DefaultContainer

func DefaultContainer() *Container

func Load

func Load(key string) *Container

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

type Option

type Option func(c *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 ..

func (*WebSocket) Upgrade

func (ws *WebSocket) Upgrade(w http.ResponseWriter, r *http.Request)

Upgrade get upgrage request

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

type WebSocketFunc

type WebSocketFunc func(WebSocketConn, error)

WebSocketFunc ..

type WebSocketOption

type WebSocketOption func(*WebSocket)

WebSocketOption ..

Jump to

Keyboard shortcuts

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