-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (36 loc) · 794 Bytes
/
Copy pathmain.go
File metadata and controls
53 lines (36 loc) · 794 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
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"time" // temporary for simulating work.
"fmt"
"menteslibres.net/gosexy/redis"
)
var rediscon *redis.Client
func main(){
//Print useless garbage to screen.
fmt.Println("Now starting worker...")
//Connect to the Redis server
rediscon = redis.New()
err := rediscon.Connect("127.0.0.1", 6379)
if err != nil{
panic("Could not connect to Redis")
}
rediscon.Select(7)
msg, err := rediscon.Ping()
if err != nil {
panic("Could not ping Redis")
} else {
fmt.Println("Pinged Redis!:"+msg)
}
fmt.Println("Connected to Redis")
dowork()
}
func dowork(){
for true{
job, err := rediscon.BRPop(0, "jobs")
if err != nil {
fmt.Println("No Job "+err.Error())
}
fmt.Println("Got a job: "+job)
time.Sleep(5 * time.Second)
}
}