switched to rate.Limiter

This commit is contained in:
2022-03-30 15:32:25 +02:00
parent ac512aec2f
commit acbfb97014
5 changed files with 40 additions and 23 deletions

View File

@@ -12,7 +12,7 @@ import (
"github.com/an0nfunc/go-steam/v3/protocol/steamlang"
"github.com/go-redis/cache/v8"
log "github.com/sirupsen/logrus"
"go.uber.org/ratelimit"
"golang.org/x/time/rate"
"google.golang.org/protobuf/proto"
"io/ioutil"
"os"
@@ -37,7 +37,7 @@ type DemoMatchLoaderConfig struct {
Db *ent.Client
Worker int
ApiKey string
RateLimit ratelimit.Limiter
RateLimit *rate.Limiter
Cache *cache.Cache
SprayTimeout int
RetryTimeout int
@@ -370,7 +370,7 @@ func (dml *DemoMatchLoader) demoWorker() {
}
}
func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl ratelimit.Limiter) error {
func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl *rate.Limiter) error {
if dml.IsLoading(demo) {
log.Infof("[DL] Skipping %s: parsing in progress", demo.ShareCode)
return nil
@@ -549,7 +549,7 @@ func (dml *DemoMatchLoader) handleDemo(demo *Demo, apiKey string, rl ratelimit.L
return nil
}
func (dml *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
func (dml *DemoMatchLoader) gcWorker(apiKey string, rl *rate.Limiter) {
for demo := range dml.parseDemo {
err := dml.handleDemo(demo, apiKey, rl)
if err != nil {