mq

package
v0.0.0-...-5a8ff1d Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBrokenIndex indicates the index is broken: crc32 mismatch
	ErrBrokenIndex = errors.New("broken index")

	// ErrClosedTopic indicates put to closed topic
	ErrClosedTopic = errors.New("closed topic")
)

Functions

This section is empty.

Types

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue can have many topics.

func NewQueue

func NewQueue(path string) (q *Queue, err error)

NewQueue create a message queue.

func (*Queue) Close

func (q *Queue) Close()

Close release all resources.

func (*Queue) Get

func (q *Queue) Get(id uint32) (t *Topic, err error)

Get returns a topic from queue, will create a new one if is not exist.

func (*Queue) Topics

func (q *Queue) Topics() (res []*Topic)

Topics returns all topics in this queue.

type Topic

type Topic struct {
	// contains filtered or unexported fields
}

Topic is a FIFO queue to put and get messages.

func (*Topic) Close

func (t *Topic) Close() (err error)

Close marks this topic as closed. Message can not be put to this topic after closed, but is still able to read pending messages.

func (*Topic) Count

func (t *Topic) Count() int64

Count returns all message had been put to this topic

func (*Topic) Drop

func (t *Topic) Drop(b []byte) error

Drop should only be called after Peek and with the right message FIXME: dangous if drop wrong message...

func (*Topic) Get

func (t *Topic) Get() (b []byte, err error)

Get returns a message in topic and drop it.

func (*Topic) ID

func (t *Topic) ID() uint32

ID returns unique topic id

func (*Topic) Peek

func (t *Topic) Peek() (b []byte, err error)

Peek only returns the message, won't drop it.

func (*Topic) Pending

func (t *Topic) Pending() int64

Pending returns messages can be get.

func (*Topic) Put

func (t *Topic) Put(b []byte) (err error)

Put a message to this topic.

Jump to

Keyboard shortcuts

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