- What is lamoda/tactician-rate-limit used for?
- It is a Tactician middleware that adds rate limiting to command execution on the command bus. It caps how often commands run using pluggable limiters, helping prevent bursts from hitting downstream services. In a Laravel app it sits in the Tactician middleware pipeline alongside your other bus middleware.
- How do I install lamoda/tactician-rate-limit?
- Install it via Composer with composer require lamoda/tactician-rate-limit. You need a Tactician command bus in your project, and in Laravel you can wire it into your service container or bus setup. After installation, register the middleware in the Tactician command bus middleware chain.
- How do I register the rate-limit middleware on a Tactician command bus?
- Add the package middleware to the middleware list when you construct your Tactician command bus. The exact class name and constructor arguments should come from the package README and your limiter implementation. In Laravel, this usually means configuring the bus in a service provider or dedicated config class.
- What is a pluggable limiter and how do I configure one?
- The package uses limiter abstractions so you can choose or implement the rate-limiting strategy that fits your app. You supply the limiter to the middleware when registering it on the bus. This lets you back limits with your own storage, rules, or external rate limiter without changing command handlers.
- Does lamoda/tactician-rate-limit work with Laravel?
- Yes, it can be used in Laravel applications because Laravel can host a Tactician command bus and its middleware pipeline. The package is Tactician-oriented rather than a native Laravel rate limiter, so you wire it into the bus yourself. It is not a replacement for Laravel HTTP rate limiting.
- Which Laravel versions are supported?
- The provided package context does not list explicit Laravel version constraints, so check its composer.json on Packagist before upgrading. Because it targets Tactician, Laravel support depends mainly on your PHP version and how you integrate Tactician. Test against your app Laravel version in CI.
- How does rate limiting affect command execution when a limit is exceeded?
- When the configured limiter rejects a command, the middleware prevents that command from proceeding through the rest of the bus pipeline. The exact exception or return behavior depends on the limiter and middleware implementation, so review the package source and README. Your application should handle rejected commands explicitly, such as logging, retrying later, or returning a controlled error.
- Can I use lamoda/tactician-rate-limit in production?
- It can be used in production if your limiter is backed by reliable shared storage in multi-server deployments. Avoid in-memory limiters if commands run across multiple PHP workers or hosts, because limits would not be shared. Add monitoring for throttled commands and test failure behavior before deploying.
- How should I test rate-limited command execution?
- Use a fake or deterministic limiter in unit tests so you can assert allowed and rejected command paths without real delays. For integration tests, exercise the full Tactician bus with the middleware registered. In Laravel, you can bind a test limiter in the container and verify your handlers are not invoked when the limit is hit.
- What are alternatives to this package for command rate limiting?
- Alternatives include implementing a Tactician middleware yourself, using Laravel RateLimiter facade inside a command handler or middleware, or applying rate limits at the queue or HTTP boundary. Choose based on whether you need command-bus-level throttling and pluggable limiter storage. This package is a focused option when you already use Tactician.