Skip to content

Commit

Permalink
another worker pool refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Oct 24, 2023
1 parent 62f43a8 commit 01232ef
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/sync/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"runtime/debug"
"time"

"github.com/alitto/pond"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/wait"
Expand All @@ -32,19 +31,18 @@ func (engine *Engine) ControlLoop() {
}

engine.RegisterHandlers()

pool := pond.New(20, 0, pond.MinWorkers(20))
for i := 0; i < 20; i++ {
pool.TrySubmit(engine.workerLoop)
go engine.workerLoop()
}
pool.StopAndWait()
}

func (engine *Engine) workerLoop() {
log.Info("starting sync worker")
wait.PollInfinite(syncDelay, func() (done bool, err error) {
log.Info("polling for new service updates")
item, shutdown := engine.svcQueue.Get()
if shutdown {
log.Info("shutting down worker")
return true, nil
}
err = engine.processItem(item)
Expand Down

0 comments on commit 01232ef

Please sign in to comment.