Documentation ¶
Overview ¶
Package grpool implements a goroutine reusable pool.
Index ¶
- Variables
- func Broadcast(msg *SendMsg) error
- func BroadcastAll(msg *SendMsg) error
- func InitWsPool(errfun func(err interface{}))
- func Send(msg *SendMsg) error
- 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 *SendMsg))
- func (c *Client) OnOpen(h func())
- func (c *Client) OpenClient(w http.ResponseWriter, r *http.Request, head http.Header)
- func (c *Client) Send(msg *SendMsg) error
- type Config
- type Pool
- type RuntimeInfo
- type SendMsg
- func (*SendMsg) Descriptor() ([]byte, []int)
- func (m *SendMsg) GetChannel() []string
- func (m *SendMsg) GetCmd() int32
- func (m *SendMsg) GetCmdData() []byte
- func (m *SendMsg) GetDesc() string
- func (m *SendMsg) GetFromClientId() string
- func (m *SendMsg) GetLocalId() string
- func (m *SendMsg) GetMsg() string
- func (m *SendMsg) GetPriority() int32
- func (m *SendMsg) GetServerId() string
- func (m *SendMsg) GetStatus() int32
- func (m *SendMsg) GetTimestamp() int64
- func (m *SendMsg) GetToClientId() string
- func (m *SendMsg) Marshal() (dAtA []byte, err error)
- func (m *SendMsg) MarshalTo(dAtA []byte) (int, error)
- func (m *SendMsg) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*SendMsg) ProtoMessage()
- func (m *SendMsg) Reset()
- func (m *SendMsg) Size() (n int)
- func (m *SendMsg) String() string
- func (m *SendMsg) Unmarshal(dAtA []byte) error
- func (m *SendMsg) XXX_DiscardUnknown()
- func (m *SendMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SendMsg) XXX_Merge(src proto.Message)
- func (m *SendMsg) XXX_Size() int
- func (m *SendMsg) XXX_Unmarshal(b []byte) error
- 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 ¶
func BroadcastAll ¶
全局广播 广播一定要设置toClientId,这个对象可以确定广播超时消息回复对像 通过此方法进行广播的消息体,会对所有的类型和频道都进行广播
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) 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 ¶
type SendMsg ¶
type SendMsg struct { Cmd int32 `protobuf:"varint,1,opt,name=cmd,proto3" json:"cmd,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` FromClientId string `protobuf:"bytes,3,opt,name=fromClientId,proto3" json:"fromClientId,omitempty"` ToClientId string `protobuf:"bytes,4,opt,name=toClientId,proto3" json:"toClientId,omitempty"` CmdData []byte `protobuf:"bytes,5,opt,name=cmdData,proto3" json:"cmdData,omitempty"` Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"` Priority int32 `protobuf:"varint,7,opt,name=priority,proto3" json:"priority,omitempty"` LocalId string `protobuf:"bytes,8,opt,name=localId,proto3" json:"localId,omitempty"` ServerId string `protobuf:"bytes,9,opt,name=serverId,proto3" json:"serverId,omitempty"` Channel []string `protobuf:"bytes,10,rep,name=channel,proto3" json:"channel,omitempty"` Msg string `protobuf:"bytes,11,opt,name=msg,proto3" json:"msg,omitempty"` Desc string `protobuf:"bytes,12,opt,name=Desc,proto3" json:"Desc,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*SendMsg) Descriptor ¶
func (*SendMsg) GetChannel ¶
func (*SendMsg) GetCmdData ¶
func (*SendMsg) GetFromClientId ¶
func (*SendMsg) GetLocalId ¶
func (*SendMsg) GetPriority ¶
func (*SendMsg) GetServerId ¶
func (*SendMsg) GetTimestamp ¶
func (*SendMsg) GetToClientId ¶
func (*SendMsg) MarshalToSizedBuffer ¶ added in v1.1.6
func (*SendMsg) ProtoMessage ¶
func (*SendMsg) ProtoMessage()
func (*SendMsg) XXX_DiscardUnknown ¶
func (m *SendMsg) XXX_DiscardUnknown()
func (*SendMsg) XXX_Marshal ¶
func (*SendMsg) XXX_Unmarshal ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.