Documentation
¶
Overview ¶
reference: https://github.com/seomoz/qless-py
This worker does not model the way qless does it. I more or less modeled it after my own needs.
Index ¶
- Variables
- func Bool(reply interface{}, err error) (bool, error)
- func NewWorker(cli *Client, queues []string, interval int)
- type Client
- func (c *Client) Close()
- func (c *Client) Completed(start, count int) ([]string, error)
- func (c *Client) Do(name string, keysAndArgs ...interface{}) (interface{}, error)
- func (c *Client) Events() *Events
- func (c *Client) Get(jid string) (interface{}, error)
- func (c *Client) GetConfig(option string) string
- func (c *Client) GetJob(jid string) (*Job, error)
- func (c *Client) GetRecurringJob(jid string) (*RecurringJob, error)
- func (c *Client) Queue(name string) *Queue
- func (c *Client) Queues(name string) ([]*Queue, error)
- func (c *Client) SetConfig(option string, value interface{})
- func (c *Client) Tagged(tag string, start, count int) (*TaggedReply, error)
- func (c *Client) Track(jid string) (bool, error)
- func (c *Client) Tracked() (string, error)
- func (c *Client) UnsetConfig(option string)
- func (c *Client) Untrack(jid string) (bool, error)
- type Events
- type History
- type Job
- func (j *Job) Cancel()
- func (j *Job) Client() *Client
- func (j *Job) Complete() (string, error)
- func (j *Job) Depend(jids ...interface{}) (string, error)
- func (j *Job) Fail(typ, message string) (bool, error)
- func (j *Job) Heartbeat() (bool, error)
- func (j *Job) Move() (string, error)
- func (j *Job) Retry(delay int) (string, error)
- func (j *Job) SetClient(cli *Client)
- func (j *Job) Tag(tags ...interface{}) (string, error)
- func (j *Job) Track() (bool, error)
- func (j *Job) Undepend(jids ...interface{}) (string, error)
- func (j *Job) Untag(tags ...interface{}) (string, error)
- func (j *Job) Untrack() (bool, error)
- type JobCallback
- type JobFunc
- type Lua
- type Queue
- func (q *Queue) CancelAll()
- func (q *Queue) Jobs(state string, start, count int) ([]string, error)
- func (q *Queue) Pause()
- func (q *Queue) Pop(count int) ([]*Job, error)
- func (q *Queue) Put(jid, klass string, data interface{}, delay, priority int, tags []string, ...) (string, error)
- func (q *Queue) Recur(jid, klass string, data interface{}, interval, offset, priority int, ...) (string, error)
- func (q *Queue) SetClient(cli *Client)
- func (q *Queue) Unpause()
- type RecurringJob
- type StringSlice
- type TaggedReply
- type Worker
Constants ¶
This section is empty.
Variables ¶
var (
JOBSTATES = []string{"stalled", "running", "scheduled", "depends", "recurring"}
)
Functions ¶
func Bool ¶
Bool is a helper that converts a command reply to a boolean. If err is not equal to nil, then Bool returns false, err. Otherwise Bool converts the reply to boolean as follows:
Reply type Result integer value != 0, nil bulk strconv.ParseBool(reply) or r != "False", nil nil false, ErrNil other false, error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetRecurringJob ¶
func (c *Client) GetRecurringJob(jid string) (*RecurringJob, error)
func (*Client) UnsetConfig ¶
config(0, 'unset', [option])
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
func (*Events) Unsubscribe ¶
func (e *Events) Unsubscribe()
type Job ¶
type Job struct { Expires int64 Dependents StringSlice Tracked bool Tags StringSlice Jid string Retries int Data interface{} Queue string State string Remaining int Failure interface{} History []History Dependencies interface{} Klass string Priority int Worker string // contains filtered or unexported fields }
func (*Job) Complete ¶
Complete(0, jid, worker, queue, now, data, ['next', n, [('delay', d) | ('depends', '["jid1","jid2",...]')]) Completes this job returns state, error
func (*Job) Fail ¶
Fail(0, id, worker, type, message, now, [data]) Fail this job return success, error
func (*Job) Heartbeat ¶
Heartbeat(0, id, worker, now, [data]) Heartbeats this job return success, error
type JobCallback ¶
type Lua ¶
type Lua struct {
// contains filtered or unexported fields
}
func (*Lua) LoadScripts ¶
loads all the given scripts from the path
type Queue ¶
type Queue struct { Running int Name string Waiting int Recurring int Depends int Stalled int Scheduled int // contains filtered or unexported fields }
func (*Queue) Jobs ¶
Jobs(0, ('stalled' | 'running' | 'scheduled' | 'depends' | 'recurring'), now, queue, [offset, [count]])
func (*Queue) Put ¶
func (q *Queue) Put(jid, klass string, data interface{}, delay, priority int, tags []string, retries int, depends []string) (string, error)
Put(1, queue, jid, klass, data, now, delay, [priority, p], [tags, t], [retries, r], [depends, '[...]']) Puts a job into the queue returns jid, error
func (*Queue) Recur ¶
func (q *Queue) Recur(jid, klass string, data interface{}, interval, offset, priority int, tags []string, retries int) (string, error)
Recur(0, 'on', queue, jid, klass, data, now, 'interval', second, offset, [priority p], [tags t], [retries r]) Put a recurring job in this queue
type RecurringJob ¶
type RecurringJob struct { Tags StringSlice Jid string Retries int Data interface{} Queue string Interval int Count int Klass string Priority int // contains filtered or unexported fields }
func NewRecurringJob ¶
func NewRecurringJob(cli *Client) *RecurringJob
func (*RecurringJob) Cancel ¶
func (r *RecurringJob) Cancel()
func (*RecurringJob) Tag ¶
func (r *RecurringJob) Tag(tags ...interface{})
func (*RecurringJob) Untag ¶
func (r *RecurringJob) Untag(tags ...interface{})
func (*RecurringJob) Update ¶
func (r *RecurringJob) Update(opts map[string]interface{})
example: job.Update(map[string]interface{}{"priority": 5}) options:
priority int retries int interval int data interface{} klass string
type StringSlice ¶
type StringSlice []string
represents a string slice with special json unmarshalling
func (*StringSlice) UnmarshalJSON ¶
func (s *StringSlice) UnmarshalJSON(data []byte) error
type TaggedReply ¶
type TaggedReply struct { Total int Jobs StringSlice }
type Worker ¶
type Worker struct { Interval int // in time.Duration // contains filtered or unexported fields }
func (*Worker) AddService ¶
Adds all the methods in the passed interface as job functions. Job names are in the form of: name.methodname