limiter_map

package
v0.29.11-an-error-hand... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL