package comp import ( "fmt" "git.wanbits.io/joe/franklin/protos" "git.wanbits.io/joe/kettle/etcd" "git.wanbits.io/joe/kettle/utl" "time" ) var ( GEtcdc *etcd.EtcdClient ) func ConnectEtcd(c *protos.ConfConf) (*etcd.EtcdClient, error) { GEtcdc, err := etcd.New(c.Addrs, c.Username, c.Password, time.Duration(c.Timeout)*time.Second) return GEtcdc, err } func RegisterSelf(path string, c *protos.AppConf, val string) { fullpath := fmt.Sprintf("%s/%v", path, c.Id) leaseId, err := GEtcdc.PutWithLife(fullpath, val, 2) utl.ErrPanic(err) err = GEtcdc.KeepAlive(leaseId) utl.ErrPanic(err) }