-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (37 loc) · 864 Bytes
/
main.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
package main
import (
"log"
"os"
"time"
"github.com/gomodule/redigo/redis"
)
const (
ENV_REDIS_ADDRESS= "REDIS_ADDRESS"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
redisAddr, redisAddrExists := os.LookupEnv(ENV_REDIS_ADDRESS)
if !redisAddrExists {
redisAddr = "localhost:6379"
}
p := &redis.Pool{
MaxIdle: 10,
IdleTimeout: 240 * time.Second,
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", redisAddr)
if err != nil {
return nil, err
}
return c, err
},
TestOnBorrow: func(c redis.Conn, t time.Time) error {
_, err := c.Do("PING")
return err
},
}
r := newMatchRepo(p)
d := newDealer(r)
if err := startServer(d); err != nil {
log.Fatal(err)
}
}