lamoda / tactician-rate-limit
此包已被弃用,不再维护。未建议替代包。
Tactician 命令总线中间件,用于限制命令执行速率
0.1.1
2019-03-01 17:19 UTC
Requires
- php: ^7.1
- league/tactician: ^1.0
- psr/log: ^1.0
Requires (Dev)
- davedevelopment/stiphle: ^0.9.2
- phpunit/phpunit: ^7.2
Suggests
- davedevelopment/stiphle: Allow using stiphle as a rate limiter implementation
This package is auto-updated.
Last update: 2023-05-29 01:14:59 UTC
README
安装
用法非常简单
composer require lamoda/tactician-rate-limit
之后,您需要选择提供速率限制功能的库。目前有以下库提供内置支持:
要使用此库,请执行以下操作
- 通过 composer 需求
stiphle
composer require davedevelopment/stiphle
- 配置中间件
$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 ]);
如果您正在使用 Symfony:使用 lamoda/tactician-rate-limit-bundle