Documentation ¶
Index ¶
- Variables
- type Queue
- func (queue *Queue) Close() error
- func (queue *Queue) LHandle(h func([]byte) error) error
- func (queue *Queue) LPop() ([]byte, error)
- func (queue *Queue) LPush(data []byte) error
- func (queue *Queue) Len() int64
- func (queue *Queue) RHandle(h func([]byte) error) error
- func (queue *Queue) RPop() ([]byte, error)
- func (queue *Queue) RPush(data []byte) error
- type Set
- type UniqueQueue
- func (queue *UniqueQueue) Close() error
- func (queue *UniqueQueue) Has(data []byte) (bool, error)
- func (queue *UniqueQueue) LHandle(h func([]byte) error) error
- func (queue *UniqueQueue) LPop() ([]byte, error)
- func (queue *UniqueQueue) LPush(data []byte) error
- func (queue *UniqueQueue) LPushFunc(data []byte, fn func() error) error
- func (queue *UniqueQueue) Len() int64
- func (queue *UniqueQueue) RHandle(h func([]byte) error) error
- func (queue *UniqueQueue) RPop() ([]byte, error)
- func (queue *UniqueQueue) RPush(data []byte) error
- func (queue *UniqueQueue) RPushFunc(data []byte, fn func() error) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound means no elements in queue ErrNotFound = errors.New("no key found") ErrAlreadyInQueue = errors.New("value already in queue") )
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue defines a queue struct
func NewQueue ¶ added in v0.2.0
NewQueue creates a queue from a db. The keys will be prefixed with prefix and at close the db will be closed as per closeUnderlyingDB
func Open ¶
Open opens a queue from the db path or creates a queue if it doesn't exist. The keys will not be prefixed by default
func (*Queue) LHandle ¶
LHandle receives a user callback function to handle the left element of the queue, if function return nil, then delete the element, otherwise keep the element.
type Set ¶ added in v0.2.0
type Set struct {
// contains filtered or unexported fields
}
Set defines a set struct
func NewSet ¶ added in v0.2.0
NewSet creates a set from a db. The keys will be prefixed with prefix and at close the db will be closed as per closeUnderlyingDB
func OpenSet ¶ added in v0.2.0
OpenSet opens a set from the db path or creates a set if it doesn't exist. The keys will be prefixed with "set-" by default
func (*Set) Add ¶ added in v0.2.0
Add adds a member string to a key set, returns true if the member was not already present
func (*Set) Close ¶ added in v0.2.0
Close closes the set (and the underlying db if set to closeUnderlyingDB)
type UniqueQueue ¶ added in v0.2.0
type UniqueQueue struct {
// contains filtered or unexported fields
}
UniqueQueue defines an unique queue struct
func NewUniqueQueue ¶ added in v0.2.0
func NewUniqueQueue(db *leveldb.DB, queuePrefix []byte, setPrefix []byte, closeUnderlyingDB bool) (*UniqueQueue, error)
NewUniqueQueue creates a new unique queue from a db. The queue keys will be prefixed with queuePrefix and the set keys with setPrefix and at close the db will be closed as per closeUnderlyingDB
func OpenUnique ¶ added in v0.2.0
func OpenUnique(dataDir string) (*UniqueQueue, error)
OpenUnique opens an unique queue from the db path or creates a set if it doesn't exist. The keys in the queue portion will not be prefixed, and the set keys will be prefixed with "set-"
func (*UniqueQueue) Close ¶ added in v0.2.0
func (queue *UniqueQueue) Close() error
Close closes the queue (and the underlying DB if set to closeUnderlyingDB)
func (*UniqueQueue) Has ¶ added in v0.2.0
func (queue *UniqueQueue) Has(data []byte) (bool, error)
Has checks whether the data is already in the queue
func (*UniqueQueue) LHandle ¶ added in v0.2.0
func (queue *UniqueQueue) LHandle(h func([]byte) error) error
LHandle receives a user callback function to handle the left element of the queue, if the function returns nil, then delete the element, otherwise keep the element.
func (*UniqueQueue) LPop ¶ added in v0.2.0
func (queue *UniqueQueue) LPop() ([]byte, error)
LPop pops data from left of the queue
func (*UniqueQueue) LPush ¶ added in v0.2.0
func (queue *UniqueQueue) LPush(data []byte) error
LPush pushes data to the left of the queue
func (*UniqueQueue) LPushFunc ¶ added in v0.2.0
func (queue *UniqueQueue) LPushFunc(data []byte, fn func() error) error
LPushFunc pushes data to the left of the queue and calls the callback if it is added
func (*UniqueQueue) Len ¶ added in v0.2.0
func (queue *UniqueQueue) Len() int64
Len returns the length of the queue
func (*UniqueQueue) RHandle ¶ added in v0.2.0
func (queue *UniqueQueue) RHandle(h func([]byte) error) error
RHandle receives a user callback function to handle the right element of the queue, if the function returns nil, then delete the element, otherwise keep the element.
func (*UniqueQueue) RPop ¶ added in v0.2.0
func (queue *UniqueQueue) RPop() ([]byte, error)
RPop pop data from the right of the queue
func (*UniqueQueue) RPush ¶ added in v0.2.0
func (queue *UniqueQueue) RPush(data []byte) error
RPush pushes data to the right of the queue