mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
fix(docker): fixed retry mechanism
This commit is contained in:
parent
f06741428c
commit
2b4a70a550
1 changed files with 10 additions and 3 deletions
|
@ -136,12 +136,19 @@ func (w *DockerWatcher) EventsWithOptions(ctx context.Context, options DockerLis
|
|||
err = nil
|
||||
// trigger reload (clear routes)
|
||||
eventCh <- reloadTrigger
|
||||
for !w.checkConnection(ctx) {
|
||||
|
||||
retry := time.NewTicker(dockerWatcherRetryInterval)
|
||||
defer retry.Stop()
|
||||
ok := false
|
||||
for !ok {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(dockerWatcherRetryInterval):
|
||||
continue
|
||||
case <-retry.C:
|
||||
if w.checkConnection(ctx) {
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// connection successful, trigger reload (reload routes)
|
||||
|
|
Loading…
Add table
Reference in a new issue