Documentation ¶
Index ¶
- type RateLimiterMap
- func (r *RateLimiterMap) Cleanup()
- func (r *RateLimiterMap) CleanupLoop()
- func (r *RateLimiterMap) Close()
- 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)
- type RateLimiterMetadata
- func (m *RateLimiterMetadata) LastAccessed() time.Time
- func (m *RateLimiterMetadata) LastRateLimit() time.Time
- func (m *RateLimiterMetadata) Limiter() *rate.Limiter
- func (m *RateLimiterMetadata) SetLastAccessed(lastAccessed time.Time)
- func (m *RateLimiterMetadata) SetLastRateLimit(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) Cleanup ¶
func (r *RateLimiterMap) Cleanup()
Cleanup check the TTL for all keys in map and Remove isExpired keys.
func (*RateLimiterMap) CleanupLoop ¶
func (r *RateLimiterMap) CleanupLoop()
CleanupLoop starts a loop that periodically removes stale peers.
func (*RateLimiterMap) Close ¶
func (r *RateLimiterMap) Close()
Close will Close the done channel starting the final full Cleanup and stopping the Cleanup loop.
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.
type RateLimiterMetadata ¶
type RateLimiterMetadata struct {
// contains filtered or unexported fields
}
func (*RateLimiterMetadata) LastAccessed ¶
func (m *RateLimiterMetadata) LastAccessed() time.Time
LastAccessed returns RateLimiterMetadata.lastAccessed.
func (*RateLimiterMetadata) LastRateLimit ¶
func (m *RateLimiterMetadata) LastRateLimit() time.Time
LastRateLimit returns RateLimiterMetadata.lastRateLimit.
func (*RateLimiterMetadata) Limiter ¶
func (m *RateLimiterMetadata) Limiter() *rate.Limiter
Limiter returns RateLimiterMetadata.limiter..
func (*RateLimiterMetadata) SetLastAccessed ¶
func (m *RateLimiterMetadata) SetLastAccessed(lastAccessed time.Time)
SetLastAccessed sets RateLimiterMetadata.lastAccessed.
func (*RateLimiterMetadata) SetLastRateLimit ¶
func (m *RateLimiterMetadata) SetLastRateLimit(lastRateLimit time.Time)
SetLastRateLimit sets RateLimiterMetadata.lastRateLimit.