Skip to content

Commit

Permalink
Refresh per-namespace worker periodically (#4103)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnr committed Mar 25, 2023
1 parent 3d6ac72 commit 8bdfccc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion service/worker/pernamespaceworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ import (

const (
perNamespaceWorkerManagerListenerKey = "perNamespaceWorkerManager"

// Always refresh workers after this time even if there were no membership or namespace
// state changes. This is to pick up dynamic config changes (which we can't subscribe to).
refreshInterval = 10 * time.Minute
)

type (
Expand Down Expand Up @@ -216,7 +220,15 @@ func (wm *perNamespaceWorkerManager) refreshAll() {
}

func (wm *perNamespaceWorkerManager) membershipChangedListener() {
for range wm.membershipChangedCh {
loop:
for {
select {
case _, ok := <-wm.membershipChangedCh:
if !ok {
break loop
}
case <-time.After(refreshInterval):
}
wm.refreshAll()
}
}
Expand Down

0 comments on commit 8bdfccc

Please sign in to comment.