An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 6.6% on proxy.golang.org

proxy.golang.org : github.com/rorycl/keyrate

Package keyrate implements a non-locking rate-limiter for a slice of Key:Value Thing, safe for concurrent use. This simple module processes a slice of Thing where items (Thing.Value) with common keys (Thing.Key) are provided via the Get function channel at an interval at KeyRate (or longer) time intervals. Rate limiting utilises a time.Ticker to put each Thing.Value in a Thing.Key group (or "bunch") on the result channel until exhausted. The ticker is reset after each put to the channel to account for blocking delays by the consumer or contention from processing other bunches. This is not a bucket-type rate-limiting strategy with replenishing tokens. This simple solution requires items to be known upfront which are then provided back to the consumer via the Get function, on a per-bunch, rate-limited basis which is concurrent safe without the need for locking. Other solutions, such as https://github.com/sethvargo/go-limiter and https://golang.org/x/time/rate provide more features such as alternate storage backends or burstability and work well for open-ended scenarios. The first offers a `Take` function which returns a reset unix nanosecond -- when a wait is required -- utilising a refilling bucket model. The second offers a `Wait` function implemented as a token bucket which also refills. Both use mutex locking. Example with "things" which have a string key and string value: Another example with an int key and type X value: Provided under the MIT License.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/rorycl/keyrate
Keywords: golang-library , rate-limit
License: MIT
Latest release: about 1 year ago
First release: about 1 year ago
Namespace: github.com/rorycl
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 6 hours ago

    Loading...
    Readme
    Loading...