Popularity
2.5
Declining
Activity
0.0
Stable
43
3
2

Programming language: Go
License: MIT License
Tags: Utilities    

equalizer alternatives and similar packages

Based on the "Utilities" category.
Alternatively, view equalizer alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of equalizer or a related project?

Add another 'Utilities' Package

README

equalizer

Build Status GoDoc Go Report Card codecov

Rate limiters collection

About

API Quota is a very valuable resource. And while using it very carefully how do we back off in case of quota exceeded. If we continue with requests it can cause waste load and account lock in specific cases.
Distributed quota management service is a solution but what if this is not a case? Chose one of the following limiters and your preferred backoff algorithm if needed.

Equalizer

Equalizer provides the ability to manage quota based on previous responses and slow down or accelerate accordingly. It uses a bitmap of variable size which is quick and efficient.

Usage

offset := NewRandomOffset(96)
eq := NewEqualizer(96, 16, offset)

//claim quota
haveQuota := eq.Claim()

//nofify equalizer
eq.Notify(true, 10)

Benchmark results

BenchmarkEqualizerShortClaimStep-8      10000000               144 ns/op               0 B/op          0 allocs/op
BenchmarkEqualizerShortClaimRandom-8    10000000               155 ns/op               0 B/op          0 allocs/op
BenchmarkEqualizerShortNotify-8          5000000               266 ns/op               0 B/op          0 allocs/op
BenchmarkEqualizerLongClaimStep-8       10000000               143 ns/op               0 B/op          0 allocs/op
BenchmarkEqualizerLongClaimRandom-8     10000000               146 ns/op               0 B/op          0 allocs/op
BenchmarkEqualizerLongNotify-8             30000             48446 ns/op               0 B/op          0 allocs/op

Slider

Sliding window based rate limiter.

Usage

//slider with 1 second window size, 100 millis sliding interval and capacity of 32
slider := NewSlider(time.Second, time.Millisecond*100, 32)

//claim quota
haveQuota := slider.Claim()

Token bucket

Custom implementation for token bucket rate limiter with refill interval.

Usage

//bucket with capacity of 32 and 100 millis refill interval
tokenBucket := NewTokenBucket(32, time.Millisecond*100)

//claim quota
haveQuota := tokenBucket.Claim()

License

Licensed under the MIT License.


*Note that all licence references and agreements mentioned in the equalizer README section above are relevant to that project's source code only.