MCPcopy Index your code
hub / github.com/diamante-io/throttled

github.com/diamante-io/throttled @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
43 symbols 77 edges 7 files 19 documented · 44% updated 2y ago★ 229

Browse by type

Functions 28 Types & classes 15
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Throttled build status GoDoc

Package throttled implements rate limiting using the generic cell rate algorithm to limit access to resources such as HTTP endpoints.

The 2.0.0 release made some major changes to the throttled API. If this change broke your code in problematic ways or you wish a feature of the old API had been retained, please open an issue. We don't guarantee any particular changes but would like to hear more about what our users need. Thanks!

Installation

go get -u github.com/throttled/throttled

Documentation

API documentation is available on godoc.org. The following example demonstrates the usage of HTTPLimiter for rate-limiting access to an http.Handler to 20 requests per path per minute with bursts of up to 5 additional requests:

store, err := memstore.New(65536)
if err != nil {
    log.Fatal(err)
}

quota := throttled.RateQuota{throttled.PerMin(20), 5}
rateLimiter, err := throttled.NewGCRARateLimiter(store, quota)
if err != nil {
    log.Fatal(err)
}

httpRateLimiter := throttled.HTTPRateLimiter{
    RateLimiter: rateLimiter,
    VaryBy:      &throttled.VaryBy{Path: true},
}

http.ListenAndServe(":8080", httpRateLimiter.RateLimit(myHandler))

Related Projects

See throttled/gcra for a list of other projects related to rate limiting and GCRA.

Release

  1. Update CHANGELOG.md. Please use semantic versioning and the existing conventions established in the file. Commit the changes with a message like Bump version to 2.2.0.
  2. Tag master with a new version prefixed with v. For example, v2.2.0.
  3. git push origin master --tags.
  4. Publish a new release on the releases page. Copy the body from the contents of CHANGELOG.md for the version and follow other conventions from previous releases.

License

The BSD 3-clause license. Copyright (c) 2014 Martin Angers and contributors.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 15
Function 13
Struct 11
Interface 2
FuncType 1
TypeAlias 1

Languages

Go100%

Modules by API surface

rate.go23 symbols
http_test.go8 symbols
rate_test.go5 symbols
http.go4 symbols
varyby.go2 symbols
varyby_test.go1 symbols

For agents

$ claude mcp add throttled \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page