Bucket
in package
Represents a rate-limit bucket.
Tags
Table of Contents
Properties
- $checkerRunning : bool
- Whether we are checking the queue.
- $logger : LoggerInterface
- HTTP logger.
- $loop : LoopInterface
- ReactPHP event loop.
- $name : string
- Bucket name.
- $promiseV3 : mixed
- Whether react/promise v3 is used, if false, using v2.
- $queue : SplQueue
- Request queue.
- $requestLimit : int
- Number of requests allowed before reset.
- $requestRemaining : int
- Number of remaining requests before reset.
- $resetTimer : TimerInterface
- Timer to reset the bucket.
- $runRequest : callable
- Callback for when a request is ready.
Methods
- __construct() : mixed
- Bucket constructor.
- __toString() : string
- Converts a bucket to a user-readable string.
- checkQueue() : mixed
- Checks for requests in the bucket.
- enqueue() : mixed
- Enqueue a request.
- __checkQueue() : mixed
Properties
$checkerRunning
Whether we are checking the queue.
protected
bool
$checkerRunning
= false
$logger
HTTP logger.
protected
LoggerInterface
$logger
$loop
ReactPHP event loop.
protected
LoopInterface
$loop
$name
Bucket name.
protected
string
$name
$promiseV3
Whether react/promise v3 is used, if false, using v2.
protected
mixed
$promiseV3
= true
$queue
Request queue.
protected
SplQueue
$queue
$requestLimit
Number of requests allowed before reset.
protected
int
$requestLimit
$requestRemaining
Number of remaining requests before reset.
protected
int
$requestRemaining
$resetTimer
Timer to reset the bucket.
protected
TimerInterface
$resetTimer
$runRequest
Callback for when a request is ready.
protected
callable
$runRequest
Methods
__construct()
Bucket constructor.
public
__construct(string $name, LoopInterface $loop, LoggerInterface $logger, callable $runRequest) : mixed
Parameters
- $name : string
- $loop : LoopInterface
- $logger : LoggerInterface
- $runRequest : callable
__toString()
Converts a bucket to a user-readable string.
public
__toString() : string
Return values
stringcheckQueue()
Checks for requests in the bucket.
public
checkQueue() : mixed
enqueue()
Enqueue a request.
public
enqueue(Request $request) : mixed
Parameters
- $request : Request
__checkQueue()
protected
__checkQueue() : mixed