mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-24 04:58:31 -05:00
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:
+8
-3
@@ -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
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user