mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 16:28:30 +02:00
refactor: clean up code and fix race condition in idlewatcher
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/yusing/go-proxy/internal/net/types"
|
||||
"github.com/yusing/go-proxy/internal/watcher/health"
|
||||
)
|
||||
|
||||
// Setup implements types.Stream.
|
||||
@@ -50,7 +49,7 @@ func (w *Watcher) wakeFromStream() error {
|
||||
w.resetIdleTimer()
|
||||
|
||||
// pass through if container is already ready
|
||||
if w.ready.Load() {
|
||||
if w.ready() {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -78,7 +77,9 @@ func (w *Watcher) wakeFromStream() error {
|
||||
default:
|
||||
}
|
||||
|
||||
if w.Status() == health.StatusHealthy {
|
||||
if ready, err := w.checkUpdateState(); err != nil {
|
||||
return err
|
||||
} else if ready {
|
||||
w.resetIdleTimer()
|
||||
w.Debug().Msg("container is ready, passing through to " + w.hc.URL().String())
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user