add delay after error while watching change fix

This commit is contained in:
yusing
2024-03-12 20:33:59 +00:00
parent 0aef8f2931
commit a0f890fed7
4 changed files with 4 additions and 11 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"fmt"
"sync"
"time"
"github.com/docker/docker/client"
"github.com/golang/glog"
@@ -18,7 +17,6 @@ type Provider struct {
routes map[string]Route // id -> Route
dockerClient *client.Client
mutex sync.Mutex
lastUpdate time.Time
}
func (p *Provider) GetProxyConfigs() ([]*ProxyConfig, error) {
@@ -33,10 +31,6 @@ func (p *Provider) GetProxyConfigs() ([]*ProxyConfig, error) {
}
}
func (p *Provider) needUpdate() bool {
return p.lastUpdate.Add(1 * time.Second).Before(time.Now())
}
func (p *Provider) StopAllRoutes() {
p.mutex.Lock()
defer p.mutex.Unlock()
@@ -69,11 +63,6 @@ func (p *Provider) BuildStartRoutes() {
p.mutex.Lock()
defer p.mutex.Unlock()
if !p.needUpdate() {
return
}
p.lastUpdate = time.Now()
p.routes = make(map[string]Route)
cfgs, err := p.GetProxyConfigs()