config: add jitter interval for watcher to avoid dos
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/unistack-org/micro/v3/util/jitter"
|
||||
rutil "github.com/unistack-org/micro/v3/util/reflect"
|
||||
)
|
||||
|
||||
@@ -302,7 +302,7 @@ type defaultWatcher struct {
|
||||
}
|
||||
|
||||
func (w *defaultWatcher) run() {
|
||||
ticker := time.NewTicker(w.wopts.Interval)
|
||||
ticker := jitter.NewTicker(w.wopts.MinInterval, w.wopts.MaxInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
src := w.opts.Struct
|
||||
|
||||
Reference in New Issue
Block a user