Documentation ¶
Overview ¶
Package relyq provides a reliable queue backed by redis
Index ¶
- type ArbitraryTask
- type Config
- type Ider
- type Listener
- type Queue
- func (q *Queue) BProcess(timeout_secs int, task Ider) error
- func (q *Queue) Close() error
- func (q *Queue) Fail(task Ider) error
- func (q *Queue) Finish(task Ider) error
- func (q *Queue) Listen(example Ider) *Listener
- func (q *Queue) Process(task Ider) (ok bool, err error)
- func (q *Queue) Push(task Ider) error
- func (q *Queue) Remove(subq *simpleq.Queue, task Ider, keepInStorage ...bool) error
- type Storage
- type StructuredTask
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArbitraryTask ¶
type ArbitraryTask map[string]interface{}
An arbitrary task object that can be directly used by applications
func (ArbitraryTask) Id ¶
func (t ArbitraryTask) Id() []byte
type Config ¶
type Config struct { // Required: Prefix on simpleq.Queue key names for redis Prefix string // Field in any object which contains a unique identifier // Defaults to "id" IdField string // Redis delimeter. Defaults to ":" Delimiter string // Clean finish (i.e. no Done queue) // Defaults to false UseDoneQueue bool // Should we keep the task stored after they are done? // Defaults to false KeepDoneTasks bool }
Configuration for Relyq
type Ider ¶
type Ider interface { // Ensure an id exists by creating it if necessary. Always return it. Id() []byte }
A useful alias for a task
type Listener ¶
type Queue ¶
type Queue struct { // The underlying simpleqs Todo, Doing, Done, Failed *simpleq.Queue Storage Storage Cfg *Config // contains filtered or unexported fields }
A reliable redis-backed queue
func (*Queue) Finish ¶
Move a task to the Done queue if in use If a task is not in use, delete if CleanFinishKeepStorage is false Sometimes a task is in the Failed queue already (maybe timeout) so we check there if not in Finish
type Storage ¶
type Storage interface { // Get a task object Get(taskid []byte, task interface{}) error // Save a task object Set(task interface{}, taskid []byte) error // Delete the task object in the storage Del(taskid []byte) error // End the Storage connection io.Closer }
Storage interface
type StructuredTask ¶
type StructuredTask struct {
RqId string `json:"id"`
}
A struct that implements Ider to be used in task objects for applications. Use like so:
type MyTask struct { StructuredTask OtherFields string }
func (*StructuredTask) Id ¶
func (t *StructuredTask) Id() []byte
Click to show internal directories.
Click to hide internal directories.