Documentation
¶
Overview ¶
`qatar` is a simple queuing system backed by an on-disk key-value store using `pebble`. You can enqueue or dequeue a payload of type `[]byte`
Index ¶
- type Item
- type Q
- func (q *Q) Close()
- func (q *Q) Count() (int, error)
- func (q *Q) Delete(id ksuid.KSUID) error
- func (q *Q) Dequeue() (*Item, error)
- func (q *Q) DequeueAfter(id ksuid.KSUID) (*Item, error)
- func (q *Q) Enqueue(data []byte) (id ksuid.KSUID, err error)
- func (q *Q) EnqueueWithId(data []byte, id ksuid.KSUID) error
- func (q *Q) Peek() (*Item, error)
- func (q *Q) PeekAfter(id ksuid.KSUID) (*Item, error)
- func (q *Q) PeekMulti(num int) ([]Item, error)
- func (q *Q) PeekMultiAfter(num int, id ksuid.KSUID) ([]Item, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Q ¶
type Q struct {
// contains filtered or unexported fields
}
Struct corresponding to a queue.
func CreateQ ¶
Creates a queue in the specified directory. If this directory already exists, then we get an error. If opening an existing queue, use `OpenQ` instead.
func NewQ ¶
Sets up a new queue, with the `pebble` store in directory `dirName`. Do remember to call `Close()` on the instance of `*Q` that is returned.
func OpenQ ¶
Opens an existing queue in the specified directory. If this directory does not exist, then an error is returned. To create a queue, use the `CreateQ` method.
func (*Q) Count ¶
Returns the number of items in the queue. Note that this consists of scanning the entire queue, and can be very expensive. There is no caching provided.
func (*Q) Delete ¶
Deletes the specified `id` from the queue. This can be in any position, and need not be at the tail of the queue.
func (*Q) Dequeue ¶
`Dequeue` operates as a `Peek()` and then a `Delete()` of the Item from the queue
func (*Q) DequeueAfter ¶
Peeks and deletes the first item after the provided id.
func (*Q) Enqueue ¶
Enqueues data and returns the id of the corresponding entry in the key value store. This id can be used to directly delete the entry.
func (*Q) EnqueueWithId ¶
Enqueue items with a specified id