PHP code example of lamoda / tactician-rate-limit
1. Go to this page and download the library: Download lamoda/tactician-rate-limit library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lamoda / tactician-rate-limit example snippets
$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
]);