Skip to content

Commit 6b747d3

Browse files
dnryycptt
authored andcommitted
Refresh per-namespace worker periodically (#4103)
1 parent aabbae0 commit 6b747d3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

service/worker/pernamespaceworker.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ import (
5959

6060
const (
6161
perNamespaceWorkerManagerListenerKey = "perNamespaceWorkerManager"
62+
63+
// Always refresh workers after this time even if there were no membership or namespace
64+
// state changes. This is to pick up dynamic config changes (which we can't subscribe to).
65+
refreshInterval = 10 * time.Minute
6266
)
6367

6468
type (
@@ -216,7 +220,15 @@ func (wm *perNamespaceWorkerManager) refreshAll() {
216220
}
217221

218222
func (wm *perNamespaceWorkerManager) membershipChangedListener() {
219-
for range wm.membershipChangedCh {
223+
loop:
224+
for {
225+
select {
226+
case _, ok := <-wm.membershipChangedCh:
227+
if !ok {
228+
break loop
229+
}
230+
case <-time.After(refreshInterval):
231+
}
220232
wm.refreshAll()
221233
}
222234
}

0 commit comments

Comments
 (0)