forked from kdar/goqless
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexamples_test.go
67 lines (54 loc) · 1.76 KB
/
examples_test.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
57
58
59
60
61
62
63
64
65
66
67
package goqless
// import (
// "fmt"
// // "github.com/garyburd/redigo/redis"
// // "time"
// )
// func ExampleGoqless_1() {
// c, err := Dial("", "6379")
// if err != nil {
// panic(err)
// }
// defer c.Close()
// jid := "f5b66400bf027c191ddb80a85785b03eb9765456"
// c.Track(jid)
// q := c.Queue("goqless_testing_queue")
// putreply, err := q.Put(jid, "dunno", `{"hey": "there"}`, -1, -1, []string{}, -1, []string{})
// fmt.Println("Put:", putreply, err)
// //fmt.Println(q.Recur(jid, "dunno", `{"hey": "there"}`, 5, 0, 0, []string{}, 1))
// jobs, err := q.Pop(1)
// fmt.Printf("Pop: %s %s %v\n", jobs[0].Queue, jobs[0].Data, err)
// fmt.Print("Complete: ")
// fmt.Println(jobs[0].Complete())
// //wg.Wait()
// // Output:
// // Put: f5b66400bf027c191ddb80a85785b03eb9765456 <nil>
// // Pop: goqless_testing_queue map[hey:there] <nil>
// // Complete: complete <nil>
// }
// func ExampleGoqless_2() {
// c, err := Dial("", "6379")
// if err != nil {
// panic(err)
// }
// defer c.Close()
// jid := "f5b66400bf027c191ddb80a85785b03eb9765457"
// c.Track(jid)
// q := c.Queue("goqless_testing_queue")
// data := struct {
// Str string
// }{
// "a string",
// }
// putreply, err := q.Put(jid, "dunno", data, -1, -1, []string{}, -1, []string{})
// fmt.Println("Put:", putreply, err)
// //fmt.Println(q.Recur(jid, "dunno", `{"hey": "there"}`, 5, 0, 0, []string{}, 1))
// jobs, err := q.Pop(1)
// fmt.Printf("Pop: %s %v %v\n", jobs[0].Queue, jobs[0].Data, err)
// fmt.Print("Fail: ")
// fmt.Println(jobs[0].Fail("justbecause", "i said so"))
// // Output:
// // Put: f5b66400bf027c191ddb80a85785b03eb9765457 <nil>
// // Pop: goqless_testing_queue map[Str:a string] <nil>
// // Fail: true <nil>
// }