Documentation ¶
Overview ¶
Package msgq implements a simple, finite-sized message queue. It can be used as a building block for a message processor pool.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRxOverrun = errors.New("rx overrun")
ErrRxOverrun signals that a receive queue has been overrun.
Functions ¶
This section is empty.
Types ¶
type MessageAdder ¶
MessageAdder enqueues a received message for processing. It returns without blocking, and may return a queue overrun error.
type MessageHandler ¶
MessageHandler is a message handler.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a finite-sized message queue.
func (*Queue) AddMessage ¶
AddMessage enqueues a received message for processing. It returns without blocking, and may return a queue overrun error.
func (*Queue) HandleMessages ¶
func (q *Queue) HandleMessages(h MessageHandler)
HandleMessages dequeues and dispatches incoming messages using the given message handler, until the message queue is closed. This function can be spawned as a background goroutine, potentially multiple times for a pool.