- What is gohany/circuitbreaker used for in Laravel?
- It is a Laravel circuit breaker package for guarding unreliable external services. It tracks failures, opens the circuit to fail fast, helps prevent cascading outages, and automatically restores traffic when services recover. Use it around HTTP calls or other integrations that can fail.
- How do I install gohany/circuitbreaker with Composer?
- Install the package with Composer using composer require gohany/circuitbreaker. Then follow the repository README for any Laravel service provider, facade, or config publishing steps. Laravel package discovery may register it automatically, but verify the package setup in your app.
- Which Laravel versions are supported by gohany/circuitbreaker?
- Check the package's composer.json and README for the supported Laravel and PHP version constraints. Verify those constraints before installing it in a production application. If you are on an older Laravel release, test compatibility in a staging app first.
- How does the circuit breaker open and close in this package?
- The package tracks failures from guarded calls and opens the circuit when the service becomes unreliable, allowing calls to fail fast. When the external service recovers, it automatically restores traffic. Review the README for the exact thresholds and recovery behavior to configure.
- Can I use gohany/circuitbreaker for external API calls in Laravel?
- Yes, it is intended for guarding unreliable external services such as APIs. Wrap external calls so failures are tracked and the circuit can open to prevent cascading outages. Pair it with appropriate timeouts, retries, and fallback behavior for production use.
- How do I test circuit breaker behavior in a Laravel app?
- Simulate failures by mocking the external service with Laravel's HTTP fake or other test doubles. Assert that repeated failures open the circuit and that recovery restores traffic. Check the package documentation for any provided testing helpers or fake implementations.
- Is gohany/circuitbreaker safe for production use?
- It is designed to help prevent cascading outages by failing fast when a dependency is unhealthy. Before production, review its configuration, failure thresholds, timeout handling, and logging behavior. Also check repository activity, open issues, and release history for maintenance signals.
- What are alternatives to gohany/circuitbreaker for Laravel?
- Alternatives include other circuit breaker Composer packages and broader resilience libraries for PHP and Laravel. Laravel's built-in HTTP client timeout and retry features can complement a breaker or partially cover similar needs. Compare maintenance status, Laravel version support, and configuration flexibility.
- How do I configure failure thresholds and recovery in gohany/circuitbreaker?
- Configuration is typically published into your Laravel config and adjusted per guarded service. Set failure counts, open duration, and recovery checks according to the package README. Tune values based on the external service's SLA and your application's tolerance for failed calls.
- Does gohany/circuitbreaker work with Laravel queues and scheduled jobs?
- It can guard external calls made from queued jobs or scheduled tasks when the package is available in that execution context. Verify how circuit state is stored and shared across workers in your setup. Test job retries, failures, and recovery behavior alongside the circuit breaker.