mb

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2016 License: BSD-2-Clause Imports: 2 Imported by: 5

README

mb

Message batching queue

Documentation

Overview

Package mb - queue with message batching feature

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("MB closed")

ErrClosed is returned when you add message to closed queue

View Source
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 New

func New(size int) *MB

New returns a new MB with given queue size. size <= 0 means unlimited

func (*MB) Add

func (mb *MB) Add(msgs ...interface{}) (err error)

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) Close

func (mb *MB) Close() (err error)

Close closes the queue All added messages will be available for Wait

func (*MB) Len

func (mb *MB) Len() (l int)

Len returning current size of queue

func (*MB) Stats

func (mb *MB) Stats() (addCount, addMsgsCount, getCount, getMsgsCount int64)

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) WaitMax

func (mb *MB) WaitMax(max int) (msgs []interface{})

WaitMax it's Wait with limit of maximum returning array size

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL