| 27 | var RpcLogicObj *RpcLogic |
| 28 | |
| 29 | func InitLogicRpcClient() { |
| 30 | once.Do(func() { |
| 31 | etcdConfigOption := &store.Config{ |
| 32 | ClientTLS: nil, |
| 33 | TLS: nil, |
| 34 | ConnectionTimeout: time.Duration(config.Conf.Common.CommonEtcd.ConnectionTimeout) * time.Second, |
| 35 | Bucket: "", |
| 36 | PersistConnection: true, |
| 37 | Username: config.Conf.Common.CommonEtcd.UserName, |
| 38 | Password: config.Conf.Common.CommonEtcd.Password, |
| 39 | } |
| 40 | d, err := etcdV3.NewEtcdV3Discovery( |
| 41 | config.Conf.Common.CommonEtcd.BasePath, |
| 42 | config.Conf.Common.CommonEtcd.ServerPathLogic, |
| 43 | []string{config.Conf.Common.CommonEtcd.Host}, |
| 44 | true, |
| 45 | etcdConfigOption, |
| 46 | ) |
| 47 | if err != nil { |
| 48 | logrus.Fatalf("init connect rpc etcd discovery client fail:%s", err.Error()) |
| 49 | } |
| 50 | LogicRpcClient = client.NewXClient(config.Conf.Common.CommonEtcd.ServerPathLogic, client.Failtry, client.RandomSelect, d, client.DefaultOption) |
| 51 | RpcLogicObj = new(RpcLogic) |
| 52 | }) |
| 53 | if LogicRpcClient == nil { |
| 54 | logrus.Fatalf("get logic rpc client nil") |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func (rpc *RpcLogic) Login(req *proto.LoginRequest) (code int, authToken string, msg string) { |
| 59 | reply := &proto.LoginResponse{} |