Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Tactician middleware providing rate limiting for command execution

Notifications You must be signed in to change notification settings

lamoda/tactician-rate-limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lamoda Tactician Rate Limit Middleware

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

About

Tactician middleware providing rate limiting for command execution

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages