-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenqueue.go
28 lines (22 loc) · 990 Bytes
/
enqueue.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
package sanji
import (
"strconv"
"strings"
)
func (s *Luffy) Enqueue(queue string, data []byte, delay uint32) (jobID string, err error) {
return s.EnqueueWithPriority(queue, data, PriorityLevelHight, delay)
}
func (s *Luffy) EnqueueWithPriority(queue string, data []byte, priority PriorityLevel, delay uint32) (jobID string, err error) {
q := s.priorityQueue(queue, priority)
return s.client.Publish(q, data, 0, 3, delay)
}
func (s *Luffy) BatchEnqueue(queue string, data []any, delay uint32) (jobID []string, err error) {
return s.BatchEnqueueWithPriority(queue, data, PriorityLevelHight, delay)
}
func (s *Luffy) BatchEnqueueWithPriority(queue string, data []any, priority PriorityLevel, delay uint32) (jobID []string, err error) {
q := s.priorityQueue(queue, priority)
return s.client.BatchPublish(q, data, 0, 3, delay)
}
func (s *Luffy) priorityQueue(queue string, priority PriorityLevel) string {
return strings.Join([]string{queue, strconv.Itoa(int(priority))}, "_")
}