-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
48 lines (38 loc) · 955 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
47
48
package main
import (
"encoding/json"
"log"
"time"
"github.com/abronan/valkeyrie"
"github.com/abronan/valkeyrie/store"
"github.com/abronan/valkeyrie/store/redis"
)
func init() {
redis.Register()
//boltdb.Register()
//etcd.Register()
}
type service struct {
Addr string `json:"addr"`
SNI string `json:"sni"`
Name string `json:"bing"`
}
func main() {
// Initialize a new store with redis
kv, err := valkeyrie.NewStore(
store.REDIS,
[]string{"127.0.0.1:6379"},
&store.Config{
ConnectionTimeout: 10 * time.Second,
},
)
if err != nil {
log.Fatal("Cannot create store redis")
}
google := &service{Addr: "172.217.19.46:443", SNI: "www.google.com", Name: "google"}
encGoogle, _ := json.Marshal(google)
bing := &service{Addr: "13.107.21.200:443", SNI: "www.bing.com", Name: "bing"}
encBing, _ := json.Marshal(bing)
kv.Put("/tcprouter/service/google", encGoogle, nil)
kv.Put("/tcprouter/service/bing", encBing, nil)
}