Overview

Namespaces

  • bandwidthThrottle
    • tokenBucket
      • storage
        • scope

Classes

  • BlockingConsumer
  • Rate
  • TokenBucket

Exceptions

  • TimeoutException
  • TokenBucketException
  • Overview
  • Namespace
  • Class

Class BlockingConsumer

Blocking token bucket consumer.

Final
Namespace: bandwidthThrottle\tokenBucket
License: WTFPL
Author: Markus Malkusch markus@malkusch.de
Link: Donations
Located at BlockingConsumer.php
Methods summary
public
# __construct( bandwidthThrottle\tokenBucket\TokenBucket $bucket, integer|null $timeout = null )

Set the token bucket and an optional timeout.

Set the token bucket and an optional timeout.

Parameters

$bucket
The token bucket.
$timeout
Optional timeout in seconds.
public
# consume( integer $tokens )

Consumes tokens.

Consumes tokens.

If the underlying token bucket doesn't have sufficient tokens, the consumer blocks until it can consume the tokens.

Parameters

$tokens
The token amount.

Throws

LengthException
The token amount is larger than the bucket's capacity.
bandwidthThrottle\tokenBucket\storage\StorageException
The stored microtime could not be accessed.
bandwidthThrottle\tokenBucket\TimeoutException
The timeout was exceeded.
API documentation generated by ApiGen