-
Notifications
You must be signed in to change notification settings - Fork 2
/
job_recurring.go
56 lines (47 loc) · 1.08 KB
/
job_recurring.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package qless
import (
"reflect"
"strings"
)
type RecurringJob struct {
Tags StringSlice
Jid string
Retries int
Data interface{}
Queue string
Interval int
Count int
Klass string
Priority int
c *Client
}
func (r *RecurringJob) Update(opts map[string]interface{}) {
args := []interface{}{"recur", timestamp(), "update", r.Jid}
vOf := reflect.ValueOf(r).Elem()
for key, value := range opts {
key = strings.ToLower(key)
v := vOf.FieldByName(ucfirst(key))
if v.IsValid() {
setv := reflect.ValueOf(value)
if key == "data" {
setv = reflect.ValueOf(marshal(value))
}
v.Set(setv)
args = append(args, key, value)
}
}
r.c.Do(args...)
}
func (r *RecurringJob) Cancel() {
r.c.Do("recur", timestamp(), "off", r.Jid)
}
func (r *RecurringJob) Tag(tags ...interface{}) {
args := []interface{}{"recur", timestamp(), "tag", r.Jid}
args = append(args, tags...)
r.c.Do(args...)
}
func (r *RecurringJob) Untag(tags ...interface{}) {
args := []interface{}{"recur", timestamp(), "untag", r.Jid}
args = append(args, tags...)
r.c.Do(args...)
}