-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenqueue.go
More file actions
42 lines (35 loc) · 738 Bytes
/
Copy pathenqueue.go
File metadata and controls
42 lines (35 loc) · 738 Bytes
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
package main
import (
"fmt"
"log"
"github.com/garyburd/redigo/redis"
"github.com/gocraft/work"
)
var redisPool = &redis.Pool{
MaxActive: 5,
MaxIdle: 5,
Wait: true,
Dial: func() (redis.Conn, error) {
return redis.Dial("tcp", ":6379")
},
}
var enqueuer = work.NewEnqueuer("my_app_namespace", redisPool)
func enqueueJob(job string, payload work.Q) {
_, err := enqueuer.Enqueue(job, payload)
if err != nil {
log.Fatal(err)
}
fmt.Println("Enqueued:", job, "with Paylod:", payload)
}
func enqueueEmail() {
enqueueJob(
"send_email",
work.Q{"address": "test@example.com", "subject": "hello world", "customer_id": 4},
)
}
func enqueueS3() {
enqueueJob(
"upload_s3",
work.Q{"bucket": "my-s3-bucket"},
)
}