package vehicle import ( "fmt" "os" "time" "gd_crontab/common.in/config" "github.com/smallnest/rpcx/client" "github.com/smallnest/rpcx/protocol" "github.com/smallnest/rpcx/share" ) var xcli client.XClient func init() { /*cfg, err := ini.Load("../../conf/app.conf") if err != nil { fmt.Printf("Fail to read file: %v\n\n", err) os.Exit(1) }*/ //runmode := cfg.Section("").Key("runmode").String() //etcdAddrs := strings.Split(cfg.Section("").Key("etcd_addrs").String(), ",") //encryptKey := cfg.Section("").Key("encrypt_key").String() //projectName := cfg.Section("").Key("project_name").String() // 先行于读配置 conf := config.GetConfigForK8s() //conf := config.GetConfig(projectName+"/"+runmode, encryptKey, clinit.GetEtcdClient()) if conf == nil { fmt.Printf("get conf failed\n\n") os.Exit(1) } opt := client.Option{ Retries: 1, RPCPath: share.DefaultRPCPath, ConnectTimeout: 10 * time.Second, SerializeType: protocol.JSON, CompressType: protocol.None, BackupLatency: 10 * time.Millisecond, } d := client.NewPeer2PeerDiscovery(fmt.Sprintf("tcp@%s:%s", conf.Rpc.Crontab.ServiceName, conf.Rpc.Crontab.ServicePort.String()), "") //d := client.NewEtcdDiscovery(conf.Rpc.BasePath, conf.Rpc.Crontab.Name, etcdAddrs, nil) xcli = client.NewXClient(conf.Rpc.Crontab.Name, client.Failtry, client.RandomSelect, d, opt) }