-
Notifications
You must be signed in to change notification settings - Fork 1
/
phone.go
executable file
·75 lines (61 loc) · 1.82 KB
/
phone.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
68
69
70
71
72
73
74
75
/*
* Copyright (c) 2018, https://github.com/airwide-code
* All rights reserved.
*
*
*
*/
package main
import (
"flag"
"github.com/golang/glog"
phone "github.com/airwide-code/airwide.datacenter/biz_server/phone/rpc"
"github.com/airwide-code/airwide.datacenter/mtproto"
"github.com/airwide-code/airwide.datacenter/baselib/redis_client"
"github.com/airwide-code/airwide.datacenter/baselib/mysql_client"
"github.com/BurntSushi/toml"
"fmt"
"github.com/airwide-code/airwide.datacenter/biz/dal/dao"
"github.com/airwide-code/airwide.datacenter/baselib/grpc_util"
"github.com/airwide-code/airwide.datacenter/baselib/grpc_util/service_discovery"
"google.golang.org/grpc"
)
func init() {
flag.Set("alsologtostderr", "true")
flag.Set("log_dir", "false")
}
type RpcServerConfig struct {
Addr string
}
//type RpcClientConfig struct {
// ServiceName string
// Addr string
//}
type phoneServerConfig struct{
Server *RpcServerConfig
Discovery service_discovery.ServiceDiscoveryServerConfig
// RpcClient *RpcClientConfig
Mysql []mysql_client.MySQLConfig
Redis []redis_client.RedisConfig
}
// 整合各服务,方便开发调试
func main() {
flag.Parse()
config := &phoneServerConfig{}
if _, err := toml.DecodeFile("./auth.toml", config); err != nil {
fmt.Errorf("%s\n", err)
return
}
glog.Info(config)
// 初始化mysql_client、redis_client
redis_client.InstallRedisClientManager(config.Redis)
mysql_client.InstallMysqlClientManager(config.Mysql)
// 初始化redis_dao、mysql_dao
dao.InstallMysqlDAOManager(mysql_client.GetMysqlClientManager())
dao.InstallRedisDAOManager(redis_client.GetRedisClientManager())
// Start server
grpcServer := grpc_util.NewRpcServer(config.Server.Addr, &config.Discovery)
grpcServer.Serve(func(s *grpc.Server) {
mtproto.RegisterRPCPhoneServer(s, &phone.PhoneServiceImpl{})
})
}