Documentation ¶
Index ¶
- func NewServer(config *Config) iface.IServer
- type Config
- type Message
- func (m *Message) GetBizType() string
- func (m *Message) GetContent() string
- func (m *Message) GetMsgId() uint32
- func (m *Message) GetParam() map[string]interface{}
- func (m *Message) SetBizType(bizType string)
- func (m *Message) SetContent(content string)
- func (m *Message) SetMsgId(msgId uint32)
- func (m *Message) SetParam(param map[string]interface{})
- type MsgHandle
- func (mh *MsgHandle) AddRouter(bizType string, router iface.IRouter)
- func (mh *MsgHandle) DoDbHandler(request iface.IMessage)
- func (mh *MsgHandle) DoDeadHandler(request iface.IMessage)
- func (mh *MsgHandle) DoMsgHandler(request iface.IMessage, workerID int)
- func (mh *MsgHandle) SendMsgToTaskQueue(request iface.IMessage)
- func (mh *MsgHandle) StartDbWork()
- func (mh *MsgHandle) StartDeadWork()
- func (mh *MsgHandle) StartOneWorker(workerID int, taskQueue chan iface.IMessage)
- func (mh *MsgHandle) StartWorkerPool()
- func (mh *MsgHandle) Stat() []atomic2.Int64
- func (mh *MsgHandle) Stop()
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Message ¶
func NewMessage ¶
创建一个Message消息包
func (*Message) GetBizType ¶
func (*Message) GetContent ¶
func (*Message) SetBizType ¶
func (*Message) SetContent ¶
type MsgHandle ¶
type MsgHandle struct { Apis map[string]iface.IRouter //存放每个MsgId 所对应的处理方法的map属性 WorkerPoolSize uint32 //业务工作Worker池的数量 TaskQueue []chan iface.IMessage //Worker负责取任务的消息队列 Exit chan struct{} //退出 Status bool //开启的状态 true 开启 false 关闭 Lock sync.RWMutex // 锁 Pc []atomic2.Int64 RetryKV map[string]atomic2.Int64 //计算MsgId 重试的次数 MaxRetry int64 //最大重试次数 DeadQueue chan iface.IMessage //处理失败任务的队列 DbQueue chan iface.IMessage Delay time.Duration //延迟ACK失败返回队列 Setting *Config }
func NewMsgHandle ¶
func (*MsgHandle) DoDbHandler ¶
func (*MsgHandle) DoDeadHandler ¶
func (*MsgHandle) DoMsgHandler ¶
马上以非阻塞方式处理消息
func (*MsgHandle) SendMsgToTaskQueue ¶
将消息交给TaskQueue,由worker进行处理
func (*MsgHandle) StartDbWork ¶
func (mh *MsgHandle) StartDbWork()
func (*MsgHandle) StartOneWorker ¶
启动一个Worker工作流程
Click to show internal directories.
Click to hide internal directories.