-
Notifications
You must be signed in to change notification settings - Fork 8
/
queue.go
47 lines (39 loc) · 1.07 KB
/
queue.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
package curlyq
import (
"fmt"
)
type queue struct {
name string
activeJobsList string
consumersSet string
deadJobsSet string
inflightJobsPrefix string
jobDataHash string
scheduledJobsSet string
signalList string
}
type queueOpts struct {
Name string
}
func newQueue(opts *queueOpts) *queue {
if opts.Name == "" {
panic("A queue name must be provided.")
}
activeJobsList := fmt.Sprintf("%s:active", opts.Name)
consumersSet := fmt.Sprintf("%s:consumers", opts.Name)
deadJobsSet := fmt.Sprintf("%s:dead", opts.Name)
inflightJobsPrefix := fmt.Sprintf("%s:inflight", opts.Name)
jobDataHash := fmt.Sprintf("%s:data", opts.Name)
scheduledJobsSet := fmt.Sprintf("%s:scheduled", opts.Name)
signalList := fmt.Sprintf("%s:signal", opts.Name)
return &queue{
name: opts.Name,
activeJobsList: activeJobsList,
consumersSet: consumersSet,
deadJobsSet: deadJobsSet,
inflightJobsPrefix: inflightJobsPrefix,
jobDataHash: jobDataHash,
scheduledJobsSet: scheduledJobsSet,
signalList: signalList,
}
}