Enhancement: Update go-micro kubernetes registry (#6457)

* Enhancement: Update go-micro kubernetes registry to v1.1.2-0.20230605104008-a179a6b8f8e6
This commit is contained in:
Florian Schade
2023-06-06 17:05:25 +02:00
committed by GitHub
parent fdb4d6e12f
commit 749d9b2b0d
6 changed files with 21 additions and 8 deletions
@@ -32,7 +32,6 @@ func (wr *bodyWatcher) Stop() {
return
default:
wr.stop()
close(wr.results)
}
}
@@ -51,7 +50,7 @@ func (wr *bodyWatcher) stream() {
go func() {
//nolint:errcheck
defer wr.res.Body.Close()
out:
for {
// Read a line
b, err := reader.ReadBytes('\n')
@@ -69,9 +68,15 @@ func (wr *bodyWatcher) stream() {
if err := json.Unmarshal(b, &event); err != nil {
continue
}
wr.results <- event
select {
case <-wr.ctx.Done():
break out
case wr.results <- event:
}
}
close(wr.results)
// stop the watcher
wr.Stop()
}()
+4 -1
View File
@@ -24,6 +24,7 @@ type k8sWatcher struct {
sync.RWMutex
pods map[string]*client.Pod
sync.Once
}
// build a cache of pods when the watcher starts.
@@ -164,7 +165,9 @@ func (k *k8sWatcher) Stop() {
case <-k.next:
return
default:
close(k.next)
k.Do(func() {
close(k.next)
})
}
}