queue

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MongoStoreDefaultQuery       = bson.M{"overflow": false}
	MongoStoreOverflowQuery      = bson.M{"overflow": true}
	MongoStoreToOverflowModifier = bson.M{"$set": bson.M{"overflow": true}}
	MongoStoreToDefaultModifier  = bson.M{"$set": bson.M{"overflow": false}}
	MongoStoreToDefaultChange    = mgo.Change{
		Update: bson.M{"$set": bson.M{"overflow": false}},
	}
)
View Source
var (
	ErrNoItems         = errors.New("no items")
	ErrNoOverflowItems = errors.New("no overflow items")
)

Functions

This section is empty.

Types

type Item

type Item struct {
	ID       []byte `bson:"_id"`
	Payload  []byte `bson:"payload"`
	Overflow bool   `bson:"overflow"`
}

func NewItem

func NewItem(payload []byte) Item

type MongoStore

type MongoStore struct {
	S *mgo.Session
	C *mgo.Collection
}

func NewMongoStore

func NewMongoStore(session *mgo.Session) *MongoStore

func (*MongoStore) Del

func (s *MongoStore) Del(item Item) (err error)

func (*MongoStore) Get

func (s *MongoStore) Get() (item Item, err error)

func (*MongoStore) GetItems

func (s *MongoStore) GetItems(count int) (items []Item, err error)

func (*MongoStore) Init

func (s *MongoStore) Init() (err error)

func (*MongoStore) Put

func (s *MongoStore) Put(item Item) (err error)

func (*MongoStore) Size

func (s *MongoStore) Size() (n int, err error)

type Queue

type Queue struct {
	S Store
	C chan Item
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(store Store, size int) Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() (item Item, err error)

func (*Queue) Enqueue

func (q *Queue) Enqueue(payload []byte) (err error)

func (*Queue) Init

func (q *Queue) Init() (err error)

func (*Queue) Remove

func (q *Queue) Remove(item Item) (err error)

func (*Queue) Size

func (q *Queue) Size() (n int, err error)

type Store

type Store interface {
	Init() (err error)
	Get() (item Item, err error)
	GetItems(count int) (items []Item, err error)
	Put(item Item) (err error)
	Del(item Item) (err error)
	Size() (n int, err error)
}

Jump to

Keyboard shortcuts

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