fix linter
This commit is contained in:
parent
5fb9f0f895
commit
fabaf40050
@ -8,6 +8,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Use double the CPU count for sharding
|
||||||
|
const shardsPerCoreMultiplier = 2
|
||||||
|
|
||||||
var NoopLimiter Limiter = &noopLimiter{}
|
var NoopLimiter Limiter = &noopLimiter{}
|
||||||
|
|
||||||
type token struct {
|
type token struct {
|
||||||
@ -38,7 +41,7 @@ type tokenShard struct {
|
|||||||
|
|
||||||
// NewTokensBucket creates a sharded token bucket limiter.
|
// NewTokensBucket creates a sharded token bucket limiter.
|
||||||
func NewTokensBucket(maxRPS uint32, unusedTokenTime, checkTokenTime time.Duration) Limiter {
|
func NewTokensBucket(maxRPS uint32, unusedTokenTime, checkTokenTime time.Duration) Limiter {
|
||||||
shardCount := uint32(runtime.NumCPU() * 2) // Use double the CPU count for sharding
|
shardCount := uint32(runtime.NumCPU() * shardsPerCoreMultiplier)
|
||||||
shards := make([]*tokenShard, shardCount)
|
shards := make([]*tokenShard, shardCount)
|
||||||
for i := range shards {
|
for i := range shards {
|
||||||
shards[i] = &tokenShard{tokens: make(map[string]*token)}
|
shards[i] = &tokenShard{tokens: make(map[string]*token)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user