package rate
Import Path
github.com/libp2p/go-libp2p/x/rate (on go.dev)
Dependency Relation
imports 8 packages, and imported by 2 packages
Involved Source Files
Package rate provides rate limiting functionality at a global, network, and subnet level.
Package-Level Type Names (total 5)
Limit is the configuration for a token bucket rate limiter.
The bucket has a capacity of Burst, and is refilled at a rate of RPS tokens per second.
Initially, buckets are completley full, i.e. tokens in the bucket is equal to `Burst`.
In any given time interval T seconds, maximum events allowed will be `T*RPS + Burst`.
Burst is the number of requests allowed over the RPS.
RPS is the rate of requests per second in steady state.
Limiter rate limits new streams for a service. It allows setting NetworkPrefix specific,
global, and subnet specific limits. Use 0 for no rate limiting.
The limiter maintains state that must be periodically cleaned up using Cleanup
GlobalLimit is the limit for all streams where the peer IP doesn't fall within any
of the `NetworkPrefixLimits`
NetworkPrefixLimits are limits for streams with peer IPs belonging to specific subnets.
It can be used to increase the limit for trusted networks and decrease the limit for specific networks.
SubnetRateLimiter is a rate limiter for subnets.
Allow returns true if requests for `ipAddr` are within specified rate limits
Limit rate limits a StreamHandler function.
func github.com/libp2p/go-libp2p/p2p/host/resource-manager.WithConnRateLimiters(connRateLimiter *Limiter) rcmgr.Option
PrefixLimit is a rate limit configuration that applies to a specific network prefix.
Limit Limit
Burst is the number of requests allowed over the RPS.
RPS is the rate of requests per second in steady state.
Prefix netip.Prefix
SubnetLimit is a rate limit configuration that applies to a specific subnet.
Limit Limit
Burst is the number of requests allowed over the RPS.
RPS is the rate of requests per second in steady state.
PrefixLength int
SubnetLimiter rate limits requests per ip subnet.
GracePeriod is the time to wait to remove a full capacity bucket.
Keeping a bucket around helps prevent allocations
IPv4SubnetLimits are the per subnet limits for streams with IPv4 Peers.
IPv6SubnetLimits are the per subnet limits for streams with IPv6 Peers.
Allow returns true if requests for `ipAddr` are within specified rate limits
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |