it seems like we should have some initialization method for the ratelimit library which sets this key if it doesn't exist.
err = pool.Do(radix.FlatCmd(nil, "HSET",
"status:"+serverConfig.Host,
host, serverConfig.Host,
sustainedRequests, 0,
burstRequests, 0,
pendingRequests, 0,
firstSustainedRequest, 0,
firstBurstRequest, 0,
)
hostConfig := NewRateLimitConfig(serverConfig.Host,
serverConfig.SustainedRequestLimit-1,
serverConfig.SustainedTimePeriod,
serverConfig.BurstRequestLimit-1,
serverConfig.BurstTimePeriod)
canMake, sleepTime := requestStatus.CanMakeRequest(pool, requestWeight, hostConfig)
config := RequestLimiterConfig{
host: "api.binance.com",
ratelimitConfig: RateLimitConfig{
sustainedLimit: 1200,
sustainedTimePeriod: 60,
burstLimit: 20,
burstTimePeriod: 1,
}
}
limiter, err := NewRequestLimiter(config)
That would then set the key in redis with all 0s if the key doesn't already exist and you'd be ready to call: