-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.go
48 lines (41 loc) · 947 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 (
"github.com/henrylee2cn/cfgo"
tp "github.com/henrylee2cn/teleport"
micro "github.com/xiaoenai/tp-micro"
"github.com/xiaoenai/tp-micro/configer"
"github.com/xiaoenai/tp-micro/discovery"
"github.com/xiaoenai/tp-micro/model/etcd"
)
type config struct {
Server micro.SrvConfig `yaml:"server"`
Etcd etcd.EasyConfig `yaml:"etcd"`
}
func (e *config) Reload(bindFunc cfgo.BindFunc) error {
return bindFunc()
}
func main() {
cfg := &config{
Server: micro.SrvConfig{
ListenAddress: ":4040",
},
Etcd: etcd.EasyConfig{
Endpoints: []string{"http://127.0.0.1:2379"},
},
}
cfgo.MustReg("configer", cfg)
etcdClient, err := etcd.EasyNew(cfg.Etcd)
if err != nil {
tp.Fatalf("%v", err)
}
configer.InitMgr(etcdClient)
srv := micro.NewServer(
cfg.Server,
discovery.ServicePluginFromEtcd(
cfg.Server.InnerIpPort(),
etcdClient,
),
)
srv.RoutePull(configer.PullCtrl())
srv.ListenAndServe()
}