Add fetching of addresses from proxyGetConfig endpoint

This commit is contained in:
9seconds
2026-02-24 12:55:16 +01:00
parent 908842063a
commit 94d46d2c65
11 changed files with 419 additions and 80 deletions
+39
View File
@@ -0,0 +1,39 @@
package dc
import (
"context"
"time"
)
type updater struct {
logger Logger
period time.Duration
}
func (u updater) run(ctx context.Context, callback func() error) {
ticker := time.NewTicker(u.period)
defer func() {
ticker.Stop()
select {
case <-ticker.C:
default:
}
}()
for {
u.logger.Info("start update")
if err := callback(); err != nil {
u.logger.WarningError("cannot update: %w", err)
}
u.logger.Info("updated")
select {
case <-ctx.Done():
u.logger.Info("stop updating")
return
case <-ticker.C:
}
}
}