12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package provider
- import (
- "fmt"
- "os"
- "time"
- "gd_management/common.in/config"
- "github.com/smallnest/rpcx/client"
- "github.com/smallnest/rpcx/protocol"
- "github.com/smallnest/rpcx/share"
- )
- var xcli client.XClient
- func init() {
- // 先行于读配置
- //clinit.InitEtcd(etcdAddrs)
- conf := config.GetConfigForK8s()
- 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.NewEtcdDiscovery(conf.Rpc.BasePath, conf.Rpc.Management.Name, etcdAddrs, nil)
- xcli = client.NewXClient(conf.Rpc.Management.Name, client.Failtry, client.RandomSelect, d, opt)
- */
- opt := client.Option{
- Retries: 1,
- RPCPath: share.DefaultRPCPath,
- ConnectTimeout: 10 * time.Second,
- SerializeType: protocol.JSON,
- CompressType: protocol.None,
- BackupLatency: 10 * time.Millisecond,
- }
- sd := client.NewPeer2PeerDiscovery(fmt.Sprintf("tcp@%s:%s", conf.Rpc.Management.ServiceName, conf.Rpc.Management.ServicePort.String()), "")
- xcli = client.NewXClient(conf.Rpc.Management.Name, client.Failtry, client.RandomSelect, sd, opt)
- }
|