Documentation ¶
Overview ¶
Package grpool implements a goroutine reusable pool.
Index ¶
- Variables
- func Broadcast(msg *Message, channel ...string) error
- func InitWsPool(errfun func(err interface{}))
- type Client
- func (c *Client) Close()
- func (c *Client) GetRuntimeInfo() *RuntimeInfo
- func (c *Client) OnClose(h func())
- func (c *Client) OnError(h func(err error))
- func (c *Client) OnMessage(h func(msg []byte))
- func (c *Client) OnMessageString(h func(msg string))
- func (c *Client) OnOpen(h func())
- func (c *Client) OpenClient(w http.ResponseWriter, r *http.Request, head http.Header)
- func (c *Client) Send(msg *Message) error
- type Config
- type Message
- type Pool
- type RuntimeInfo
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //最大连接池缓冲处理连接对像管道长度 Max_client_channel_len = 10240 //最大全局广播缓冲处理管道长度 Max_broadcastQueue_len = 4096 //最大频道广播缓冲处理管道长度 Max_chanBroadcastQueue_len = 4096 //最大接收消息缓冲处理管道长度 Max_recvCh_len = 10240 //最大发送消息缓冲处理管道长度 Max_sendCh_len = 10240 )
Functions ¶
Types ¶
type Client ¶
type Client struct { CloseTime time.Time //连接断开的时间 Id string //标识连接的名称 IsClose chan bool //连接的状态。true为关闭 // contains filtered or unexported fields }
Client is a middleman between the websocket connection and the hub.
func (*Client) OnMessageString ¶ added in v1.4.1
监听连接对象的连接open成功的事件
func (*Client) OpenClient ¶
开启连接 serveWs handles websocket requests from the peer.
type Config ¶
type Config struct { Id string //标识连接的名称 Type string //连接类型或path Channel []string //连接注册频道类型方便广播等操作。做为一个数组存储。因为一个连接可以属多个频道 Goroutine int //每个连接开启的go程数里 默认为10 }
连接参数结构体
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Goroutine Pool
func New ¶
New creates and returns a new goroutine pool object. The parameter <limit> is used to limit the max goroutine count, which is not limited in default.
func (*Pool) Cap ¶
Cap returns the capacity of the pool. This capacity is defined when pool is created. If it returns -1 means no limit.
type RuntimeInfo ¶
Directories ¶
Path | Synopsis |
---|---|
util
|
|
gmap
Package empty provides checks for empty variables.
|
Package empty provides checks for empty variables. |
grpool
Package glist provides a concurrent-safe/unsafe doubly linked list.
|
Package glist provides a concurrent-safe/unsafe doubly linked list. |
queue
bill 2018.1.8 优先级队列[同级别先进先出]权重值越大越优先
|
bill 2018.1.8 优先级队列[同级别先进先出]权重值越大越优先 |
rwmutex
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex.
|
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex. |
Click to show internal directories.
Click to hide internal directories.