lamoda/tactician-rate-limit

This package is abandoned and no longer maintained. No replacement package was suggested.

Tactician command bus middleware for rate limiting command execution

0.1.1 2019-03-01 17:19 UTC

This package is auto-updated.

Last update: 2023-05-29 01:14:59 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Build Status

Installation

Usage is as simple as

composer require lamoda/tactician-rate-limit

After that you need to choose library that is providing rate limiting capabilities. For now there out of the box support for the following libraries:

To use this library do the following:

  1. Require stiphle via composer:
    composer require davedevelopment/stiphle
  2. Configure middleware:
    $rateLimitProvider = new MatchingCommandClassRateLimitProvider(
    	RateLimitedCommand::class,
    	3, // max commands to execute per interval
    	1000 // interval in milliseconds
    );
    
    $rateLimiter = new StiphleRateLimiterAdapter(new LeakyBucket());
    
    $rateLimitMiddleware = new RateLimitMiddleware(
    	$rateLimitProvider,
    	$rateLimiter
    );
    
    // Create command bus with this middleware:
    $commandBus = new CommandBus([
     	$rateLimitMiddleware,
     	// other middlewares
    ]);

If you are using Symfony: use lamoda/tactician-rate-limit-bundle