Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (36 sloc) 1.48 KB


Once you've chosen your rate limit strategy you can either use it directly or integrates it with some of the existing components of Tolerance.

  • Operation Runner is an Operation Runner that will run your operations based on the rate limit.

Operation Runner

The Rate Limited Operation Runner is the integration of rate limiting with operation runners. That way you can ensure that all the operations you want to run will actually run at the given time rate.

$rateLimit = /* The implementation you wants */;

$operationRunner = new RateLimitedOperationRunner(
    new SimpleOperationRunner(),
    new SleepWaiter()


By default, the identifier given to the rate limit is an empty string. The optional fourth parameter is an object implementing the ThrottlingIdentifierStrategy interface that will returns the identifier of the operation.

class ThrottlingIdentifierStrategy implements ThrottlingIdentifierStrategy
     * {@inheritdoc}
    public function getOperationIdentifier(Operation $operation)
        if ($operation instanceof MyClientOperation) {
            return sprintf(

        return 'unknown-client';