Documentation ¶
Overview ¶
Package mb - queue with message batching feature
Index ¶
- Variables
- type MB
- func (mb *MB) Add(msgs ...interface{}) (err error)
- func (mb *MB) Close() (err error)
- func (mb *MB) GetAll() (msgs []interface{})
- func (mb *MB) Len() (l int)
- func (mb *MB) Stats() (addCount, addMsgsCount, getCount, getMsgsCount int64)
- func (mb *MB) Wait() (msgs []interface{})
- func (mb *MB) WaitMax(max int) (msgs []interface{})
- func (mb *MB) WaitMin(min int) (msgs []interface{})
- func (mb *MB) WaitMinMax(min, max int) (msgs []interface{})
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("MB closed")
ErrClosed is returned when you add message to closed queue
var ErrTooManyMessages = errors.New("Too many messages")
ErrTooManyMessages means that adding more messages (at one call) than the limit
Functions ¶
This section is empty.
Types ¶
type MB ¶
type MB struct {
// contains filtered or unexported fields
}
MB - message batching object Implements queue. Based on condition variables
func (*MB) Add ¶
Add - adds new messages to queue. When queue is closed - returning ErrClosed When count messages bigger then queue size - returning ErrTooManyMessages When the queue is full - wait until will free place
func (*MB) GetAll ¶ added in v1.0.1
func (mb *MB) GetAll() (msgs []interface{})
GetAll return all messages and flush queue Works on closed queue
func (*MB) Stats ¶
Stats returning current statistic of queue usage addCount - count of calls Add addMsgsCount - count of added messages getCount - count of calls Wait getMsgsCount - count of issued messages
func (*MB) Wait ¶
func (mb *MB) Wait() (msgs []interface{})
Wait until anybody add message Returning array of accumulated messages When queue will be closed length of array will be 0
func (*MB) WaitMinMax ¶ added in v1.0.1
WaitMinMax it's Wait with limit of minimum and maximum returning array size value < 0 means no limit