1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package export
- 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() {
- // 先行于读配置
- //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.Crontab.ServiceName, conf.Rpc.Crontab.ServicePort.String()), "")
- xcli = client.NewXClient(conf.Rpc.Crontab.Name, client.Failtry, client.RandomSelect, sd, opt)
- }
|