simpleq

package
v0.0.0-...-94c23ba Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2013 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package simpleq provides a super-simple queue backed by Redis

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener struct {
	Elements chan []byte
	Errors   chan error
	// contains filtered or unexported fields
}

A listener on a queue, repeatedly calling BPop or BPopPipe

func NewListener

func NewListener(q, pipeto *Queue) *Listener

Create a new listener. Use pipeto as nil to call BPop.

func (*Listener) Close

func (l *Listener) Close() error

type Queue

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

A super simple redis-backed queue

func New

func New(pool *redis.Pool, key string) *Queue

Create a simpleq

func (*Queue) BPop

func (q *Queue) BPop(timeout_secs int) (el []byte, err error)

Block and Pop an element off the queue Use timeout_secs = 0 to block indefinitely On timeout, this DOES return an error because redigo does.

func (*Queue) BPopPipe

func (q *Queue) BPopPipe(q2 *Queue, timeout_secs int) (el []byte, err error)

Block and Pop an element out of a queue and put it in another queue atomically On timeout, this doesn't return an error because redigo doesn't.

func (*Queue) Clear

func (q *Queue) Clear() (nRemoved int64, err error)

Clear the queue of elements

func (*Queue) Close

func (q *Queue) Close() error

End this queue

func (*Queue) List

func (q *Queue) List() (elements [][]byte, err error)

List the elements in the queue

func (*Queue) Pop

func (q *Queue) Pop() (el []byte, err error)

Pop an element off the queue

func (*Queue) PopListen

func (q *Queue) PopListen() *Listener

Create a listener that calls Pop

func (*Queue) PopPipe

func (q *Queue) PopPipe(q2 *Queue) (el []byte, err error)

Pop an element out of a queue and put it in another queue atomically

func (*Queue) PopPipeListen

func (q *Queue) PopPipeListen(q2 *Queue) *Listener

Create a listener that calls PopPipe

func (*Queue) Pull

func (q *Queue) Pull(el []byte) (nRemoved int64, err error)

Pull an element out the queue (oldest if more than one)

func (*Queue) PullPipe

func (q *Queue) PullPipe(q2 *Queue, el []byte) (lengthQ2 int64, err error)

Pull an element out of the queue and push it onto another atomically Note: This will push the element regardless of the return value from pull

func (*Queue) Push

func (q *Queue) Push(el []byte) (length int64, err error)

Push an element onto the queue

func (*Queue) SPullPipe

func (q *Queue) SPullPipe(q2 *Queue, el []byte) (result int64, err error)

Safely pull an element out of the queue and push it onto another atomically Returns 0 for non-existance in first queue, or length of second queue

Jump to

Keyboard shortcuts

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