Documentation ¶
Index ¶
- type BufferMap
- func (m *BufferMap) Clear()
- func (m *BufferMap) Get(id interface{}) IBufferItem
- func (m *BufferMap) Keys() []interface{}
- func (m *BufferMap) Pop(id interface{}) IBufferItem
- func (m *BufferMap) PopAll() []IBufferItem
- func (m *BufferMap) Push(item IBufferItem) int
- func (m *BufferMap) Remove(id interface{})
- func (m *BufferMap) Size() int
- func (m *BufferMap) Values() []IBufferItem
- type BufferPostman
- type ChanDispatcher
- type ChanWorker
- type IBufferItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferPostman ¶
type BufferPostman struct { Buffer *BufferMap // contains filtered or unexported fields }
缓冲投递员
func NewBufferPostman ¶
func NewBufferPostman(limit int, duration time.Duration, target chan interface{}) *BufferPostman
新建缓冲投递员对象
type ChanDispatcher ¶
type ChanDispatcher struct { MsgQueue chan interface{} // 消息输入管道 WorkerPool chan chan interface{} // 工作管道池 // contains filtered or unexported fields }
调度对象
func NewChanDispatcher ¶
func NewChanDispatcher(msgQueue chan interface{}, maxWorkers int) *ChanDispatcher
func (*ChanDispatcher) Run ¶
func (d *ChanDispatcher) Run(callback func(workerId int, msg interface{}))
type ChanWorker ¶
type ChanWorker struct { ID int // 工作对象编号 WorkerPool chan chan interface{} // 工作管道池,实例化时由调度器传入 JobChannel chan interface{} // 工作管道 // contains filtered or unexported fields }
工作对象封装
func NewChanWorker ¶
func NewChanWorker(workerId int, workerPool chan chan interface{}) *ChanWorker
func (*ChanWorker) Start ¶
func (w *ChanWorker) Start(callback func(workerId int, msg interface{}))
type IBufferItem ¶
type IBufferItem interface { BufferID() interface{} // 去重用的键,包括后续消费消息,如果需要也可以根据这个键做散列处理 Reduce(oldVal IBufferItem) IBufferItem // 接口实现类中实现此方法,以实现累加之类的多态的业务逻辑,当然最简单不做其他处理直接返回新的对象值自身也行 }
缓冲消息接口
Click to show internal directories.
Click to hide internal directories.