Documentation ¶
Index ¶
- Constants
- Variables
- func GetCommunityTopicParentChannelID(channelID string) string
- func GetFakeChannelIDWith(fromUID, toUID string) string
- func GetFromUIDAndToUIDWith(channelID string) (string, string)
- func GetHomeDir() (string, error)
- func MarshalMessage(version uint8, m *Message) []byte
- func UnmarshalMessage(data []byte, m *Message) error
- type APIServer
- type Channel
- func (c *Channel) AddAllowlist(uids []string)
- func (c *Channel) AddDenylist(uids []string)
- func (c *Channel) AddSubscriber(uid string)
- func (c *Channel) AddSubscribers(uids []string)
- func (c *Channel) AddTmpSubscriber(uid string)
- func (c *Channel) AddTmpSubscribers(uids []string)
- func (c *Channel) Allow(uid string) (bool, wkproto.ReasonCode)
- func (c *Channel) GetAllSubscribers() []string
- func (c *Channel) GetAllTmpSubscribers() []string
- func (c *Channel) IsDenylist(uid string) bool
- func (c *Channel) IsSubscriber(uid string) bool
- func (c *Channel) IsTmpSubscriber(uid string) bool
- func (c *Channel) LoadData() error
- func (c *Channel) Put(messages []*Message, customSubscribers []string, fromUID string, ...) error
- func (c *Channel) RealSubscribers(customSubscribers []string) ([]string, error)
- func (c *Channel) RemoveAllSubscriber()
- func (c *Channel) RemoveAllTmpSubscriber()
- func (c *Channel) RemoveAllowlist(uids []string)
- func (c *Channel) RemoveDenylist(uids []string)
- func (c *Channel) RemoveSubscriber(uid string)
- func (c *Channel) RemoveSubscribers(uids []string)
- func (c *Channel) RemoveTmSubscriber(uid string)
- func (c *Channel) RemoveTmpSubscribers(uids []string)
- func (c *Channel) SetAllowlist(uids []string)
- func (c *Channel) SetDenylist(uids []string)
- type ChannelAPI
- type ChannelCreateReq
- type ChannelDeleteReq
- type ChannelInfoReq
- type ChannelInfoResp
- type ChannelManager
- func (cm *ChannelManager) CreateOrUpdatePersonChannel(uid string) error
- func (cm *ChannelManager) CreateTmpChannel(channelID string, channelType uint8, subscribers []string) error
- func (cm *ChannelManager) DeleteChannel(channelID string, channelType uint8) error
- func (cm *ChannelManager) DeleteChannelFromCache(channelID string, channelType uint8)
- func (cm *ChannelManager) GetChannel(channelID string, channelType uint8) (*Channel, error)
- func (cm *ChannelManager) GetOrCreateDataChannel(channelID string, channelType uint8) *Channel
- func (cm *ChannelManager) GetPersonChannel(channelID string, channelType uint8) (*Channel, error)
- func (cm *ChannelManager) GetTmpChannel(channelID string, channelType uint8) (*Channel, error)
- func (cm *ChannelManager) RemoveDataChannel(channelID string, channelType uint8)
- type ConnInfo
- type ConnManager
- func (c *ConnManager) AddConn(conn wknet.Conn)
- func (c *ConnManager) ExistConnsWithUID(uid string) bool
- func (c *ConnManager) GetConn(id int64) wknet.Conn
- func (c *ConnManager) GetConnCountWith(uid string, deviceFlag wkproto.DeviceFlag) (int, int)
- func (c *ConnManager) GetConnWithDeviceID(uid string, deviceID string) wknet.Conn
- func (c *ConnManager) GetConnsWith(uid string, deviceFlag wkproto.DeviceFlag) []wknet.Conn
- func (c *ConnManager) GetConnsWithUID(uid string) []wknet.Conn
- func (c *ConnManager) GetOnlineConns(uids []string) []wknet.Conn
- func (c *ConnManager) RemoveConn(conn wknet.Conn)
- func (c *ConnManager) RemoveConnWithID(id int64)
- type Connz
- type ConnzAPI
- type ConversationAPI
- type ConversationManager
- func (cm *ConversationManager) AddOrUpdateConversation(uid string, conversation *wkstore.Conversation)
- func (cm *ConversationManager) DeleteConversation(uids []string, channelID string, channelType uint8) error
- func (cm *ConversationManager) FlushConversations()
- func (cm *ConversationManager) GetConversation(uid string, channelID string, channelType uint8) *wkstore.Conversation
- func (cm *ConversationManager) GetConversations(uid string, version int64, larges []*wkproto.Channel) []*wkstore.Conversation
- func (cm *ConversationManager) PushMessage(message *Message, subscribers []string)
- func (cm *ConversationManager) SetConversationUnread(uid string, channelID string, channelType uint8, unread int, messageSeq uint32) error
- func (cm *ConversationManager) Start()
- func (cm *ConversationManager) Stop()
- type Datasource
- func (d *Datasource) GetBlacklist(channelID string, channelType uint8) ([]string, error)
- func (d *Datasource) GetChannelInfo(channelID string, channelType uint8) (*wkstore.ChannelInfo, error)
- func (d *Datasource) GetSubscribers(channelID string, channelType uint8) ([]string, error)
- func (d *Datasource) GetSystemUIDs() ([]string, error)
- func (d *Datasource) GetWhitelist(channelID string, channelType uint8) ([]string, error)
- type DeliveryManager
- type DemoServer
- type Dispatch
- type Event
- type FramePool
- func (f *FramePool) GetRecvackPackets() []*wkproto.RecvackPacket
- func (f *FramePool) GetSendPackets() []*wkproto.SendPacket
- func (f *FramePool) GetSubPackets() []*wkproto.SubPacket
- func (f *FramePool) GetSubackPackets() []*wkproto.SubackPacket
- func (f *FramePool) PutRecvackPackets(recvackPackets []*wkproto.RecvackPacket)
- func (f *FramePool) PutSendPackets(sendPackets []*wkproto.SendPacket)
- func (f *FramePool) PutSubPackets(subPackets []*wkproto.SubPacket)
- func (f *FramePool) PutSubackPackets(subackPackets []*wkproto.SubackPacket)
- type FrameWorkPool
- type IDatasource
- type Message
- func (m *Message) Decode(msg []byte) error
- func (m *Message) DeepCopy() (*Message, error)
- func (m *Message) Encode() []byte
- func (m *Message) GetMessageID() int64
- func (m *Message) GetSeq() uint32
- func (m *Message) SetSeq(seq uint32)
- func (m *Message) StreamIng() bool
- func (m *Message) StreamStart() bool
- type MessageAPI
- type MessageHeader
- type MessageOfflineNotify
- type MessageResp
- type MessageRespSlice
- type MessageSendReq
- type Mode
- type MonitorAPI
- type MonitorServer
- type OnlinestatusResp
- type Options
- func (o *Options) ConfigFileUsed() string
- func (o *Options) ConfigureWithViper(vp *viper.Viper)
- func (o *Options) GetCustomerServiceVisitorUID(channelID string) (string, bool)
- func (o *Options) HasDatasource() bool
- func (o *Options) IsFakeChannel(channelID string) bool
- func (o *Options) IsTmpChannel(channelID string) bool
- func (o *Options) WebhookGRPCOn() bool
- func (o *Options) WebhookOn() bool
- type Processor
- type PullMode
- type Queue
- type RetryQueue
- type RouteAPI
- type Server
- func (s *Server) AddIPBlacklist(ips []string)
- func (s *Server) AllowIP(ip string) bool
- func (s *Server) GetConnInfos(sortOpt SortOpt, offset, limit int) []wknet.Conn
- func (s *Server) Init(env svc.Environment) error
- func (s *Server) RemoveIPBlacklist(ips []string)
- func (s *Server) Schedule(interval time.Duration, f func()) *timingwheel.Timer
- func (s *Server) Start() error
- func (s *Server) Stop() error
- type SortOpt
- type StreamItemResp
- type SystemAPI
- type SystemUIDManager
- type TestConn
- func (t *TestConn) Authed() bool
- func (t *TestConn) Close() error
- func (t *TestConn) GetID() uint32
- func (t *TestConn) OutboundBuffered() int
- func (t *TestConn) RemoteAddr() net.Addr
- func (t *TestConn) SetAuthed(v bool)
- func (t *TestConn) SetID(id uint32)
- func (t *TestConn) SetReadDeadline(tm time.Time) error
- func (t *TestConn) SetVersion(version uint8)
- func (t *TestConn) SetWriteDeadline(tm time.Time) error
- func (t *TestConn) Version() uint8
- func (t *TestConn) Write(buf []byte) (n int, err error)
- func (t *TestConn) WriteChan() chan []byte
- type UpdateTokenReq
- type UserAPI
- type Varz
- type VarzAPI
- type Webhook
Constants ¶
const ( // EventMsgOffline 离线消息 EventMsgOffline = "msg.offline" // EventMsgNotify 消息通知(将所有消息通知到第三方程序) EventMsgNotify = "msg.notify" // EventOnlineStatus 用户在线状态 EventOnlineStatus = "user.onlinestatus" )
Variables ¶
var ( ErrChannelNotFound = fmt.Errorf("channel not found") ErrParamInvalid = fmt.Errorf("param invalid") )
var (
VERSION = "4.0.0" // 服务器版本
)
Functions ¶
func GetCommunityTopicParentChannelID ¶
GetCommunityTopicParentChannelID 获取社区话题频道的父频道ID
func GetFakeChannelIDWith ¶
GetFakeChannelIDWith GetFakeChannelIDWith
func GetFromUIDAndToUIDWith ¶ added in v1.1.6
func GetHomeDir ¶ added in v1.1.9
func MarshalMessage ¶
MarshalMessage MarshalMessage
func UnmarshalMessage ¶
UnmarshalMessage UnmarshalMessage
Types ¶
type Channel ¶
type Channel struct { *wkstore.ChannelInfo wklog.Log // contains filtered or unexported fields }
func NewChannel ¶
func NewChannel(channelInfo *wkstore.ChannelInfo, s *Server) *Channel
NewChannel NewChannel
func (*Channel) AddSubscriber ¶
AddSubscriber Add subscribers
func (*Channel) AddSubscribers ¶
func (*Channel) AddTmpSubscriber ¶
func (*Channel) AddTmpSubscribers ¶
func (*Channel) Allow ¶
func (c *Channel) Allow(uid string) (bool, wkproto.ReasonCode)
Allow Whether to allow sending of messages If it is in the white list or not in the black list, it is allowed to send
func (*Channel) GetAllSubscribers ¶
GetAllSubscribers 获取所有订阅者
func (*Channel) GetAllTmpSubscribers ¶
func (*Channel) IsTmpSubscriber ¶
IsTmpSubscriber 是否是临时订阅者
func (*Channel) RealSubscribers ¶
real subscribers
func (*Channel) RemoveAllSubscriber ¶
func (c *Channel) RemoveAllSubscriber()
RemoveAllSubscriber 移除所有订阅者
func (*Channel) RemoveAllTmpSubscriber ¶
func (c *Channel) RemoveAllTmpSubscriber()
RemoveAllTmpSubscriber 移除所有临时订阅者
func (*Channel) RemoveAllowlist ¶
RemoveAllowlist 移除白名单
func (*Channel) RemoveDenylist ¶
RemoveDenylist 移除黑名单
func (*Channel) RemoveSubscriber ¶
RemoveSubscriber 移除订阅者
func (*Channel) RemoveSubscribers ¶
func (*Channel) RemoveTmSubscriber ¶
func (*Channel) RemoveTmpSubscribers ¶
func (*Channel) SetAllowlist ¶
SetAllowlist SetAllowlist
type ChannelAPI ¶
ChannelAPI ChannelAPI
type ChannelCreateReq ¶
type ChannelCreateReq struct { ChannelInfoReq Subscribers []string `json:"subscribers"` // 订阅者 }
ChannelCreateReq 频道创建请求
type ChannelDeleteReq ¶
type ChannelDeleteReq struct { ChannelID string `json:"channel_id"` // 频道ID ChannelType uint8 `json:"channel_type"` // 频道类型 }
ChannelDeleteReq 删除频道请求
type ChannelInfoReq ¶
type ChannelInfoReq struct { ChannelID string `json:"channel_id"` // 频道ID ChannelType uint8 `json:"channel_type"` // 频道类型 Large int `json:"large"` // 是否是超大群 Ban int `json:"ban"` // 是否封禁频道(封禁后此频道所有人都将不能发消息,除了系统账号) Disband int `json:"disband"` // 是否解散频道 }
ChannelInfoReq ChannelInfoReq
func (ChannelInfoReq) ToChannelInfo ¶
func (c ChannelInfoReq) ToChannelInfo() *wkstore.ChannelInfo
type ChannelInfoResp ¶
type ChannelInfoResp struct { Large int `json:"large"` // 是否是超大群 Ban int `json:"ban"` // 是否封禁频道(封禁后此频道所有人都将不能发消息,除了系统账号) Disband int `json:"disband"` // 是否解散频道 }
func (ChannelInfoResp) ToChannelInfo ¶
func (c ChannelInfoResp) ToChannelInfo() *wkstore.ChannelInfo
type ChannelManager ¶
ChannelManager 频道管理
func NewChannelManager ¶
func NewChannelManager(s *Server) *ChannelManager
NewChannelManager 创建一个频道管理者
func (*ChannelManager) CreateOrUpdatePersonChannel ¶
func (cm *ChannelManager) CreateOrUpdatePersonChannel(uid string) error
CreateOrUpdatePersonChannel 创建或更新个人频道
func (*ChannelManager) CreateTmpChannel ¶
func (cm *ChannelManager) CreateTmpChannel(channelID string, channelType uint8, subscribers []string) error
CreateTmpChannel 创建临时频道
func (*ChannelManager) DeleteChannel ¶
func (cm *ChannelManager) DeleteChannel(channelID string, channelType uint8) error
DeleteChannel 删除频道
func (*ChannelManager) DeleteChannelFromCache ¶
func (cm *ChannelManager) DeleteChannelFromCache(channelID string, channelType uint8)
DeleteChannelFromCache DeleteChannelFromCache
func (*ChannelManager) GetChannel ¶
func (cm *ChannelManager) GetChannel(channelID string, channelType uint8) (*Channel, error)
GetChannel 获取频道
func (*ChannelManager) GetOrCreateDataChannel ¶ added in v1.1.1
func (cm *ChannelManager) GetOrCreateDataChannel(channelID string, channelType uint8) *Channel
func (*ChannelManager) GetPersonChannel ¶
func (cm *ChannelManager) GetPersonChannel(channelID string, channelType uint8) (*Channel, error)
GetPersonChannel 创建临时频道
func (*ChannelManager) GetTmpChannel ¶
func (cm *ChannelManager) GetTmpChannel(channelID string, channelType uint8) (*Channel, error)
GetTmpChannel 获取临时频道
func (*ChannelManager) RemoveDataChannel ¶ added in v1.1.1
func (cm *ChannelManager) RemoveDataChannel(channelID string, channelType uint8)
type ConnInfo ¶
type ConnInfo struct { ID int64 `json:"id"` // 连接ID UID string `json:"uid"` // 用户uid IP string `json:"ip"` // 客户端IP Port int `json:"port"` // 客户端端口 LastActivity time.Time `json:"last_activity"` // 最后一次活动时间 Uptime string `json:"uptime"` // 启动时间 Idle string `json:"idle"` // 客户端闲置时间 PendingBytes int `json:"pending_bytes"` // 等待发送的字节数 InMsgs int64 `json:"in_msgs"` // 流入的消息数 OutMsgs int64 `json:"out_msgs"` // 流出的消息数量 InBytes int64 `json:"in_bytes"` // 流入的字节数量 OutBytes int64 `json:"out_bytes"` // 流出的字节数量 Device string `json:"device"` // 设备 DeviceID string `json:"device_id"` // 设备ID Version uint8 `json:"version"` // 客户端协议版本 }
type ConnManager ¶
func NewConnManager ¶
func NewConnManager(s *Server) *ConnManager
func (*ConnManager) AddConn ¶
func (c *ConnManager) AddConn(conn wknet.Conn)
func (*ConnManager) ExistConnsWithUID ¶
func (c *ConnManager) ExistConnsWithUID(uid string) bool
func (*ConnManager) GetConnCountWith ¶
func (c *ConnManager) GetConnCountWith(uid string, deviceFlag wkproto.DeviceFlag) (int, int)
GetConnCountWith 获取设备的在线数量和用户所有设备的在线数量
func (*ConnManager) GetConnWithDeviceID ¶ added in v1.2.1
func (c *ConnManager) GetConnWithDeviceID(uid string, deviceID string) wknet.Conn
func (*ConnManager) GetConnsWith ¶
func (c *ConnManager) GetConnsWith(uid string, deviceFlag wkproto.DeviceFlag) []wknet.Conn
func (*ConnManager) GetConnsWithUID ¶
func (c *ConnManager) GetConnsWithUID(uid string) []wknet.Conn
func (*ConnManager) GetOnlineConns ¶
func (c *ConnManager) GetOnlineConns(uids []string) []wknet.Conn
GetOnlineConns 传一批uids 返回在线的uids
func (*ConnManager) RemoveConn ¶
func (c *ConnManager) RemoveConn(conn wknet.Conn)
func (*ConnManager) RemoveConnWithID ¶
func (c *ConnManager) RemoveConnWithID(id int64)
type ConversationAPI ¶
ConversationAPI ConversationAPI
func NewConversationAPI ¶
func NewConversationAPI(s *Server) *ConversationAPI
NewConversationAPI NewConversationAPI
type ConversationManager ¶
ConversationManager ConversationManager
func NewConversationManager ¶
func NewConversationManager(s *Server) *ConversationManager
NewConversationManager NewConversationManager
func (*ConversationManager) AddOrUpdateConversation ¶
func (cm *ConversationManager) AddOrUpdateConversation(uid string, conversation *wkstore.Conversation)
func (*ConversationManager) DeleteConversation ¶
func (cm *ConversationManager) DeleteConversation(uids []string, channelID string, channelType uint8) error
DeleteConversation 删除最近会话
func (*ConversationManager) FlushConversations ¶
func (cm *ConversationManager) FlushConversations()
FlushConversations 同步最近会话
func (*ConversationManager) GetConversation ¶
func (cm *ConversationManager) GetConversation(uid string, channelID string, channelType uint8) *wkstore.Conversation
func (*ConversationManager) GetConversations ¶
func (cm *ConversationManager) GetConversations(uid string, version int64, larges []*wkproto.Channel) []*wkstore.Conversation
GetConversations GetConversations
func (*ConversationManager) PushMessage ¶
func (cm *ConversationManager) PushMessage(message *Message, subscribers []string)
PushMessage PushMessage
func (*ConversationManager) SetConversationUnread ¶
func (cm *ConversationManager) SetConversationUnread(uid string, channelID string, channelType uint8, unread int, messageSeq uint32) error
SetConversationUnread set unread data from conversation
type Datasource ¶
type Datasource struct {
// contains filtered or unexported fields
}
Datasource Datasource
func (*Datasource) GetBlacklist ¶
func (d *Datasource) GetBlacklist(channelID string, channelType uint8) ([]string, error)
GetBlacklist 获取频道的黑名单
func (*Datasource) GetChannelInfo ¶
func (d *Datasource) GetChannelInfo(channelID string, channelType uint8) (*wkstore.ChannelInfo, error)
func (*Datasource) GetSubscribers ¶
func (d *Datasource) GetSubscribers(channelID string, channelType uint8) ([]string, error)
GetSubscribers 获取频道的订阅者
func (*Datasource) GetSystemUIDs ¶
func (d *Datasource) GetSystemUIDs() ([]string, error)
GetSystemUIDs 获取系统账号
func (*Datasource) GetWhitelist ¶
func (d *Datasource) GetWhitelist(channelID string, channelType uint8) ([]string, error)
GetWhitelist 获取频道的白明单
type DeliveryManager ¶
func NewDeliveryManager ¶
func NewDeliveryManager(s *Server) *DeliveryManager
type DemoServer ¶ added in v1.1.3
func NewDemoServer ¶ added in v1.1.3
func NewDemoServer(s *Server) *DemoServer
NewDemoServer new一个demo server
type Dispatch ¶
func NewDispatch ¶
type Event ¶
type Event struct { Event string `json:"event"` // 事件标示 Data interface{} `json:"data"` // 事件数据 }
Event Event
type FramePool ¶ added in v1.1.1
type FramePool struct {
// contains filtered or unexported fields
}
func NewFramePool ¶ added in v1.1.1
func NewFramePool() *FramePool
func (*FramePool) GetRecvackPackets ¶ added in v1.1.1
func (f *FramePool) GetRecvackPackets() []*wkproto.RecvackPacket
func (*FramePool) GetSendPackets ¶ added in v1.1.1
func (f *FramePool) GetSendPackets() []*wkproto.SendPacket
func (*FramePool) GetSubPackets ¶ added in v1.1.1
func (*FramePool) GetSubackPackets ¶ added in v1.1.1
func (f *FramePool) GetSubackPackets() []*wkproto.SubackPacket
func (*FramePool) PutRecvackPackets ¶ added in v1.1.1
func (f *FramePool) PutRecvackPackets(recvackPackets []*wkproto.RecvackPacket)
func (*FramePool) PutSendPackets ¶ added in v1.1.1
func (f *FramePool) PutSendPackets(sendPackets []*wkproto.SendPacket)
func (*FramePool) PutSubPackets ¶ added in v1.1.1
func (*FramePool) PutSubackPackets ¶ added in v1.1.1
func (f *FramePool) PutSubackPackets(subackPackets []*wkproto.SubackPacket)
type FrameWorkPool ¶
type FrameWorkPool struct {
// contains filtered or unexported fields
}
func NewFrameWorkPool ¶
func NewFrameWorkPool() *FrameWorkPool
func (*FrameWorkPool) Submit ¶
func (f *FrameWorkPool) Submit(task func())
type IDatasource ¶
type IDatasource interface { // 获取订阅者 GetSubscribers(channelID string, channelType uint8) ([]string, error) // 获取黑名单 GetBlacklist(channelID string, channelType uint8) ([]string, error) // 获取白名单 GetWhitelist(channelID string, channelType uint8) ([]string, error) // 获取系统账号的uid集合 系统账号可以给任何人发消息 GetSystemUIDs() ([]string, error) // 获取频道信息 GetChannelInfo(channelID string, channelType uint8) (*wkstore.ChannelInfo, error) }
IDatasource 数据源第三方应用可以提供
type Message ¶
type Message struct { *wkproto.RecvPacket ToUID string // 接受者 Subscribers []string // 订阅者 如果此字段有值 则表示消息只发送给指定的订阅者 // contains filtered or unexported fields }
func (*Message) GetMessageID ¶
func (*Message) StreamStart ¶ added in v1.1.4
type MessageAPI ¶
MessageAPI MessageAPI
type MessageHeader ¶
type MessageHeader struct { NoPersist int `json:"no_persist"` // Is it not persistent RedDot int `json:"red_dot"` // Whether to show red dot SyncOnce int `json:"sync_once"` // This message is only synchronized or consumed once }
MessageHeader Message header
type MessageOfflineNotify ¶
type MessageOfflineNotify struct { MessageResp ToUIDs []string `json:"to_uids"` Compress string `json:"compress,omitempty"` // 压缩ToUIDs 如果为空 表示不压缩 为gzip则采用gzip压缩 CompresssToUIDs []byte `json:"compress_to_uids,omitempty"` // 已压缩的to_uids SourceID int64 `json:"source_id,omitempty"` // 来源节点ID }
type MessageResp ¶
type MessageResp struct { Header MessageHeader `json:"header"` // 消息头 Setting uint8 `json:"setting"` // 设置 MessageID int64 `json:"message_id"` // 服务端的消息ID(全局唯一) MessageIDStr string `json:"message_idstr"` // 服务端的消息ID(全局唯一) ClientMsgNo string `json:"client_msg_no"` // 客户端消息唯一编号 StreamNo string `json:"stream_no,omitempty"` // 流编号 StreamSeq uint32 `json:"stream_seq,omitempty"` // 流序号 StreamFlag wkproto.StreamFlag `json:"stream_flag,omitempty"` // 流标记 MessageSeq uint32 `json:"message_seq"` // 消息序列号 (用户唯一,有序递增) FromUID string `json:"from_uid"` // 发送者UID ChannelID string `json:"channel_id"` // 频道ID ChannelType uint8 `json:"channel_type"` // 频道类型 Topic string `json:"topic,omitempty"` // 话题ID Expire uint32 `json:"expire"` // 消息过期时间 Timestamp int32 `json:"timestamp"` // 服务器消息时间戳(10位,到秒) Payload []byte `json:"payload"` // 消息内容 Streams []*StreamItemResp `json:"streams,omitempty"` // 消息流内容 }
MessageResp 消息返回
type MessageRespSlice ¶
type MessageRespSlice []*MessageResp
MessageRespSlice MessageRespSlice
func (MessageRespSlice) Len ¶
func (m MessageRespSlice) Len() int
func (MessageRespSlice) Less ¶
func (m MessageRespSlice) Less(i, j int) bool
func (MessageRespSlice) Swap ¶
func (m MessageRespSlice) Swap(i, j int)
type MessageSendReq ¶
type MessageSendReq struct { Header MessageHeader `json:"header"` // 消息头 ClientMsgNo string `json:"client_msg_no"` // 客户端消息编号(相同编号,客户端只会显示一条) StreamNo string `json:"stream_no"` // 消息流编号 FromUID string `json:"from_uid"` // 发送者UID ChannelID string `json:"channel_id"` // 频道ID ChannelType uint8 `json:"channel_type"` // 频道类型 Expire uint32 `json:"expire"` // 消息过期时间 Subscribers []string `json:"subscribers"` // 订阅者 如果此字段有值,表示消息只发给指定的订阅者 Payload []byte `json:"payload"` // 消息内容 }
MessageSendReq 消息发送请求
type MonitorAPI ¶
type MonitorServer ¶
func NewMonitorServer ¶
func NewMonitorServer(s *Server) *MonitorServer
func (*MonitorServer) Start ¶
func (m *MonitorServer) Start()
func (*MonitorServer) Stop ¶
func (m *MonitorServer) Stop() error
type OnlinestatusResp ¶
type Options ¶
type Options struct { ID int64 // 节点ID Mode Mode // 模式 debug 测试 release 正式 bench 压力测试 HTTPAddr string // http api的监听地址 默认为 0.0.0.0:5001 Addr string // tcp监听地址 例如:tcp://0.0.0.0:5100 RootDir string // 根目录 DataDir string // 数据目录 GinMode string // gin框架的模式 WSAddr string // websocket 监听地址 例如:ws://0.0.0.0:5200 WSSAddr string // wss 监听地址 例如:wss://0.0.0.0:5210 WSTLSConfig *tls.Config WSSConfig struct { CertFile string // 证书文件 KeyFile string // 私钥文件 } Logger struct { Dir string // 日志存储目录 Level zapcore.Level LineNum bool // 是否显示代码行数 } Monitor struct { On bool // 是否开启监控 Addr string // 监控地址 默认为 0.0.0.0:5300 } Demo struct { On bool // 是否开启demo Addr string // demo服务地址 默认为 0.0.0.0:5172 } External struct { IP string // 外网IP TCPAddr string // 节点的TCP地址 对外公开,APP端长连接通讯 格式: ip:port WSAddr string // 节点的wsAdd地址 对外公开 WEB端长连接通讯 格式: ws://ip:port WSSAddr string // 节点的wssAddr地址 对外公开 WEB端长连接通讯 格式: wss://ip:port MonitorAddr string // 对外访问的监控地址 APIUrl string // 对外访问的API基地址 格式: http://ip:port } Channel struct { CacheCount int // 频道缓存数量 CreateIfNoExist bool // 如果频道不存在是否创建 SubscriberCompressOfCount int // 订订阅者数组多大开始压缩(离线推送的时候订阅者数组太大 可以设置此参数进行压缩 默认为0 表示不压缩 ) } TmpChannel struct { Suffix string // 临时频道的后缀 CacheCount int // 临时频道缓存数量 } Webhook struct { HTTPAddr string // webhook的http地址 通过此地址通知数据给第三方 格式为 http://xxxxx GRPCAddr string // webhook的grpc地址 如果此地址有值 则不会再调用HttpAddr配置的地址,格式为 ip:port MsgNotifyEventPushInterval time.Duration // 消息通知事件推送间隔,默认500毫秒发起一次推送 MsgNotifyEventCountPerPush int // 每次webhook消息通知事件推送消息数量限制 默认一次请求最多推送100条 MsgNotifyEventRetryMaxCount int // 消息通知事件消息推送失败最大重试次数 默认为5次,超过将丢弃 } Datasource struct { Addr string // 数据源地址 ChannelInfoOn bool // 是否开启频道信息获取 } Conversation struct { On bool // 是否开启最近会话 CacheExpire time.Duration // 最近会话缓存过期时间 (这个是热数据缓存时间,并非最近会话数据的缓存时间) SyncInterval time.Duration // 最近会话同步间隔 SyncOnce int // 当多少最近会话数量发送变化就保存一次 UserMaxCount int // 每个用户最大最近会话数量 默认为500 } ManagerToken string // 管理者的token ManagerUID string // 管理者的uid ManagerTokenOn bool // 管理者的token是否开启 Proto wkproto.Protocol // 悟空IM protocol Version string UnitTest bool // 是否开启单元测试 HandlePoolSize int ConnIdleTime time.Duration // 连接空闲时间 超过此时间没数据传输将关闭 TimingWheelTick time.Duration // The time-round training interval must be 1ms or more TimingWheelSize int64 // Time wheel size UserMsgQueueMaxSize int // 用户消息队列最大大小,超过此大小此用户将被限速,0为不限制 TokenAuthOn bool // 是否开启token验证 不配置将根据mode属性判断 debug模式下默认为false release模式为true EventPoolSize int // 事件协程池大小,此池主要处理im的一些通知事件 比如webhook,上下线等等 默认为1024 WhitelistOffOfPerson bool // 是否关闭个人白名单验证 DeliveryMsgPoolSize int // 投递消息协程池大小,此池的协程主要用来将消息投递给在线用户 默认大小为 10240 MessageRetry struct { Interval time.Duration // 消息重试间隔,如果消息发送后在此间隔内没有收到ack,将会在此间隔后重新发送 MaxCount int // 消息最大重试次数 ScanInterval time.Duration // 每隔多久扫描一次超时队列,看超时队列里是否有需要重试的消息 } SlotNum int // 槽数量 DeadlockCheck bool // 是否开启死锁检查 PprofOn bool // 是否开启pprof // contains filtered or unexported fields }
func NewOptions ¶
func NewOptions() *Options
func NewTestOptions ¶
func (*Options) ConfigFileUsed ¶ added in v1.1.8
func (*Options) ConfigureWithViper ¶
func (*Options) GetCustomerServiceVisitorUID ¶
获取客服频道的访客id
func (*Options) IsFakeChannel ¶
IsFakeChannel 是fake频道
func (*Options) IsTmpChannel ¶
IsTmpChannel 是否是临时频道
func (*Options) WebhookGRPCOn ¶
WebhookGRPCOn 是否配置了webhook grpc地址
type Processor ¶
func NewProcessor ¶
type RetryQueue ¶
type RetryQueue struct {
// contains filtered or unexported fields
}
RetryQueue 重试队列
func (*RetryQueue) Stop ¶
func (r *RetryQueue) Stop()
type Server ¶
func (*Server) AddIPBlacklist ¶ added in v1.1.9
func (*Server) GetConnInfos ¶ added in v1.0.9
func (*Server) RemoveIPBlacklist ¶ added in v1.1.9
type SortOpt ¶
type SortOpt string
const ( ByID SortOpt = "id" // 通过连接id排序 ByIDDesc SortOpt = "idDesc" // 通过连接id排序 ByInMsg SortOpt = "inMsg" // 通过收到消息排序 ByInMsgDesc SortOpt = "inMsgDesc" // 通过收到消息排序 ByOutMsg SortOpt = "outMsg" // 通过发送消息排序 ByOutMsgDesc SortOpt = "outMsgDesc" // 通过发送消息排序 ByInBytes SortOpt = "inBytes" // 通过收到字节数排序 ByInBytesDesc SortOpt = "inBytesDesc" // 通过收到字节数排序 ByOutBytes SortOpt = "outBytes" // 通过发送字节数排序 ByOutBytesDesc SortOpt = "outBytesDesc" // 通过发送字节数排序 ByPendingBytes SortOpt = "pendingBytes" // 通过等待发送字节数排序 ByPendingBytesDesc SortOpt = "pendingBytesDesc" // 通过等待发送字节数排序 ByUptime SortOpt = "uptime" // 通过启动时间排序 ByUptimeDesc SortOpt = "uptimeDesc" // 通过启动时间排序 )
type StreamItemResp ¶ added in v1.1.4
type SystemUIDManager ¶
type SystemUIDManager struct {
// contains filtered or unexported fields
}
SystemUIDManager System uid management
func NewSystemUIDManager ¶
func NewSystemUIDManager(s *Server) *SystemUIDManager
NewSystemUIDManager NewSystemUIDManager
func (*SystemUIDManager) AddSystemUIDs ¶
func (s *SystemUIDManager) AddSystemUIDs(uids []string) error
AddSystemUID AddSystemUID
func (*SystemUIDManager) LoadIfNeed ¶
func (s *SystemUIDManager) LoadIfNeed() error
LoadIfNeed LoadIfNeed
func (*SystemUIDManager) RemoveSystemUIDs ¶
func (s *SystemUIDManager) RemoveSystemUIDs(uids []string) error
RemoveSystemUID RemoveSystemUID
func (*SystemUIDManager) SystemUID ¶
func (s *SystemUIDManager) SystemUID(uid string) bool
SystemUID Is it a system account?
type TestConn ¶
type TestConn struct {
// contains filtered or unexported fields
}
func NewTestConn ¶
func NewTestConn() *TestConn
func (*TestConn) OutboundBuffered ¶
func (*TestConn) RemoteAddr ¶
func (*TestConn) SetVersion ¶
type UpdateTokenReq ¶
type UpdateTokenReq struct { UID string `json:"uid"` // 用户唯一uid Token string `json:"token"` // 用户的token DeviceFlag wkproto.DeviceFlag `json:"device_flag"` // 设备标识 0.app 1.web DeviceLevel wkproto.DeviceLevel `json:"device_level"` // 设备等级 0.为从设备 1.为主设备 }
UpdateTokenReq 更新token请求
type Varz ¶
type Varz struct { ServerID string `json:"server_id"` // 服务端ID ServerName string `json:"server_name"` // 服务端名称 Version string `json:"version"` // 服务端版本 Connections int `json:"connections"` // 当前连接数量 Uptime string `json:"uptime"` // 上线时间 Goroutine int `json:"goroutine"` // goroutine数量 Mem int64 `json:"mem"` // 内存 CPU float64 `json:"cpu"` // cpu InMsgs int64 `json:"in_msgs"` // 流入消息数量 OutMsgs int64 `json:"out_msgs"` // 流出消息数量 InBytes int64 `json:"in_bytes"` // 流入字节数量 OutBytes int64 `json:"out_bytes"` // 流出字节数量 SlowClients int64 `json:"slow_clients"` // 慢客户端数量 RetryQueue int64 `json:"retry_queue"` // 重试队列数量 TCPAddr string `json:"tcp_addr"` // tcp地址 WSAddr string `json:"ws_addr"` // ws地址 WSSAddr string `json:"wss_addr"` // wss地址 MonitorAddr string `json:"monitor_addr"` // 监控地址 MonitorOn int `json:"monitor_on"` // 监控是否开启 Commit string `json:"commit"` // git commit id CommitDate string `json:"commit_date"` // git commit date TreeState string `json:"tree_state"` // git tree state APIURL string `json:"api_url"` // api地址 ManagerUID string `json:"manager_uid"` // 管理员uid ManagerTokenOn int `json:"manager_token_on"` // 管理员token是否开启 Conns []*ConnInfo `json:"conns,omitempty"` // 连接信息 }
func CreateVarz ¶ added in v1.1.1
type Webhook ¶
func NewWebhook ¶
func (*Webhook) Offline ¶
func (w *Webhook) Offline(uid string, deviceFlag wkproto.DeviceFlag, id int64, onlineCount int, totalOnlineCount int)
Offline 用户离线 id 为用户在当前系统中的socket id left 为剩余在线数量
Source Files ¶
- api_channel.go
- api_connz.go
- api_conversation.go
- api_message.go
- api_monitor.go
- api_route.go
- api_system.go
- api_user.go
- api_varz.go
- channel.go
- channel_manager.go
- common.go
- conn_context.go
- conn_manager.go
- conversation.go
- datasource.go
- delivery_manager.go
- dispatch.go
- framepool.go
- in_flight_pqueue.go
- model.go
- options.go
- processor.go
- queue.go
- retry_queue.go
- server.go
- server_demo.go
- server_http.go
- server_monitor.go
- systemuid_manager.go
- test.go
- webbhook.go
- workpool.go