@@ -38,7 +38,7 @@ func (d *etcdDiscovery) Discover(target string) (<-chan []xregistry.Instance, er
3838func (d * etcdDiscovery ) watch (ch chan <- []xregistry.Instance , serviceName string ) {
3939 prefix := fmt .Sprintf ("%s/%s/" , etcdPrefix , serviceName )
4040
41- update := func () []xregistry.Instance {
41+ update := func (serviceName string ) []xregistry.Instance {
4242 resp , err := d .client .Get (context .Background (), prefix , clientv3 .WithPrefix ())
4343 if err != nil {
4444 xlog .Warn ("etcd discovery watch" , xlog .FieldErr (err ), xlog .Any ("service name" , serviceName ))
@@ -53,16 +53,16 @@ func (d *etcdDiscovery) watch(ch chan<- []xregistry.Instance, serviceName string
5353 xlog .Warn ("etcd discovery watch unmarshal service name" , xlog .FieldErr (err ), xlog .Any ("service name" , serviceName ))
5454 }
5555 }
56- xlog .Info ("service discovery etcd" , xlog .FieldValue (xstring .Json (i )))
56+ xlog .Info ("etcd service discovery" , xlog . Any ( "service name" , serviceName ) , xlog .FieldValue (xstring .Json (i )))
5757 return i
5858 }
59- if i := update (); len (i ) > 0 {
59+ if i := update (serviceName ); len (i ) > 0 {
6060 ch <- i
6161 }
6262
6363 eventCh := d .client .Watch (context .Background (), prefix , clientv3 .WithPrefix ())
6464 for range eventCh {
65- ch <- update ()
65+ ch <- update (serviceName )
6666 }
6767 return
6868}
0 commit comments