From ab73418b18a223f9c5ea94d96f1a17dd2c52aa7b Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Mon, 25 Jan 2021 17:38:56 +0300 Subject: [PATCH] Make throttle listener running on instantiating --- throttle.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/throttle.go b/throttle.go index 86f2434..eaeb1b7 100644 --- a/throttle.go +++ b/throttle.go @@ -28,13 +28,15 @@ func NewThrottle(ctx context.Context, cfg *Config) *Throttle { } } - return &Throttle{ + t := &Throttle{ lastTimestamp: -1, queueChan: make(chan *req, cfg.MaxCapacity), config: *cfg, running: false, ctx: ctx, } + t.run() + return t } func (t *Throttle) run() {