throttled

Package throttled implements rate limiting access to resources such as HTTP endpoints.

  • 所有者: throttled/throttled
  • 平台:
  • 許可證: BSD 3-Clause "New" or "Revised" License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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))

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.

主要指標

概覽
名稱與所有者throttled/throttled
主編程語言Go
編程語言Go (語言數: 3)
平台
許可證BSD 3-Clause "New" or "Revised" License
所有者活动
創建於2014-02-19 12:13:32
推送於2025-01-23 17:00:34
最后一次提交2025-01-23 09:00:11
發布數26
最新版本名稱v2.13.0 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數1.5k
關注者數23
派生數97
提交數215
已啟用問題?
問題數46
打開的問題數9
拉請求數55
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?