libp2p
Preparing search index...
@libp2p/utils
rate-limiter
RateLimiter
Class RateLimiter
Index
Constructors
constructor
Properties
block
Duration
duration
exec
Evenly
exec
Evenly
Min
Delay
Ms
key
Prefix
memory
Storage
points
Methods
block
consume
delete
get
get
Key
parse
Key
penalty
reward
set
Constructors
constructor
new
RateLimiter
(
opts
?:
RateLimiterInit
)
:
RateLimiter
Parameters
opts
:
RateLimiterInit
= {}
Returns
RateLimiter
Properties
Protected
block
Duration
blockDuration
:
number
Protected
duration
duration
:
number
Protected
exec
Evenly
execEvenly
:
boolean
Protected
exec
Evenly
Min
Delay
Ms
execEvenlyMinDelayMs
:
number
Protected
key
Prefix
keyPrefix
:
string
Readonly
memory
Storage
memoryStorage
:
MemoryStorage
Protected
points
points
:
number
Methods
block
block
(
key
:
string
,
secDuration
:
number
)
:
RateLimiterResult
Block any key for secDuration seconds
Parameters
key
:
string
secDuration
:
number
Returns
RateLimiterResult
consume
consume
(
key
:
string
,
pointsToConsume
?:
number
,
options
?:
GetKeySecDurationOptions
,
)
:
Promise
<
RateLimiterResult
>
Parameters
key
:
string
pointsToConsume
:
number
= 1
options
:
GetKeySecDurationOptions
= {}
Returns
Promise
<
RateLimiterResult
>
delete
delete
(
key
:
string
)
:
void
Parameters
key
:
string
Returns
void
get
get
(
key
:
string
)
:
undefined
|
RateLimiterResult
Parameters
key
:
string
Returns
undefined
|
RateLimiterResult
get
Key
getKey
(
key
:
string
)
:
string
Parameters
key
:
string
Returns
string
parse
Key
parseKey
(
rlKey
:
string
)
:
string
Parameters
rlKey
:
string
Returns
string
penalty
penalty
(
key
:
string
,
points
?:
number
,
options
?:
GetKeySecDurationOptions
,
)
:
RateLimiterResult
Parameters
key
:
string
points
:
number
= 1
options
:
GetKeySecDurationOptions
= {}
Returns
RateLimiterResult
reward
reward
(
key
:
string
,
points
?:
number
,
options
?:
GetKeySecDurationOptions
,
)
:
RateLimiterResult
Parameters
key
:
string
points
:
number
= 1
options
:
GetKeySecDurationOptions
= {}
Returns
RateLimiterResult
set
set
(
key
:
string
,
points
:
number
,
secDuration
?:
number
)
:
RateLimiterResult
Parameters
key
:
string
points
:
number
secDuration
:
number
= 0
Returns
RateLimiterResult
Settings
Member Visibility
Protected
Inherited
External
Theme
OS
Light
Dark
On This Page
Constructors
constructor
Properties
block
Duration
duration
exec
Evenly
exec
Evenly
Min
Delay
Ms
key
Prefix
memory
Storage
points
Methods
block
consume
delete
get
get
Key
parse
Key
penalty
reward
set
libp2p
Loading...
Block any key for secDuration seconds