Documentation ¶
Index ¶
- type RateLimiterMap
- func (r *RateLimiterMap) CleanupLoop(ctx irrecoverable.SignalerContext)
- func (r *RateLimiterMap) Get(peerID peer.ID) (*rateLimiterMetadata, bool)
- func (r *RateLimiterMap) Remove(peerID peer.ID)
- func (r *RateLimiterMap) Store(peerID peer.ID, lmtr *rate.Limiter)
- func (r *RateLimiterMap) UpdateLastRateLimit(peerID peer.ID, lastRateLimit time.Time)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiterMap ¶
type RateLimiterMap struct {
// contains filtered or unexported fields
}
RateLimiterMap stores a rateLimiterMetadata for each peer in an underlying map.
func NewLimiterMap ¶
func NewLimiterMap(ttl, cleanupInterval time.Duration) *RateLimiterMap
func (*RateLimiterMap) CleanupLoop ¶
func (r *RateLimiterMap) CleanupLoop(ctx irrecoverable.SignalerContext)
CleanupLoop starts a loop that periodically removes stale peers. This func blocks until the signaler context is canceled, when context is canceled the limiter map is cleaned up before the cleanup loop exits.
func (*RateLimiterMap) Get ¶
func (r *RateLimiterMap) Get(peerID peer.ID) (*rateLimiterMetadata, bool)
Get returns limiter in RateLimiterMap map
func (*RateLimiterMap) Remove ¶
func (r *RateLimiterMap) Remove(peerID peer.ID)
Remove deletes peerID key from underlying map.
func (*RateLimiterMap) Store ¶
func (r *RateLimiterMap) Store(peerID peer.ID, lmtr *rate.Limiter)
Store stores limiter in RateLimiterMap map
func (*RateLimiterMap) UpdateLastRateLimit ¶
func (r *RateLimiterMap) UpdateLastRateLimit(peerID peer.ID, lastRateLimit time.Time)
UpdateLastRateLimit sets the lastRateLimit field of the rateLimiterMetadata for a peer.
Click to show internal directories.
Click to hide internal directories.