Download the PHP package gohany/circuitbreaker-symfony-bundle without Composer

On this page you can find all versions of the php package gohany/circuitbreaker-symfony-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package circuitbreaker-symfony-bundle

CI codecov

Gohany CircuitBreaker Symfony Bundle

This bundle wires gohany/circuitbreaker into Symfony, with first-class support for:

This README is intentionally recipe-first: pick the implementation that matches the problem you’re solving.

Install

Concepts (what you’re wiring)

The bundle focuses on Symfony configuration + service wiring. The underlying behaviour lives in the core library (gohany/circuitbreaker).

Quickstart (minimal config)

1) Register a Redis client adapter service

2) Configure one pool and one pipeline

Redis client service

The bundle expects a service that implements:

If you use ext-redis (\Redis), you can register the adapter from the core lib:

Configuration (profiles + shared pools)

Symfony already supports per-environment config (e.g. config/packages/prod/…).

On top of that, this bundle supports profiles selected by env var:

That makes it easy to run different pipelines in api vs worker while still sharing the same Redis-backed pool ids, so all processes cooperate on the same concurrency budget.

Example

Different profile, same pool id (shared capacity)

All processes that point at the same Redis and the same pool id share the same global concurrency cap and lane caps.

Doctrine semantics (connect-gate, query-observe)

Use connect_pipeline to block new connections under load / circuit open.

Use query_pipeline to record failures and drive circuit state, without necessarily blocking already-open connections.

This matches the pattern:

block connecting, but once connected do not attempt to block; failed queries contribute to circuit state

Doctrine composed lanes (parent share + child priority)

Doctrine DBAL middleware can compose multiple acquisitions per action:

Notes:

Common implementation recipes

1) “Protect the DB from connection storms” (connect-gate)

Use a bulkhead + circuit breaker around connect().

2) “Observe query failures to drive circuit state” (query-observe)

Use a circuit breaker around query execution without a bulkhead.

3) “Keep API fast while workers drain in the background” (profiles)

Run different profiles per process type while sharing the same Redis-backed pool IDs.

Typical split:

Select profile via GOHANY_CB_PROFILE (default env var name).

4) Lane naming strategies (how to get priority lanes)

Lanes are just strings. Good patterns:

Rule of thumb: prefer stable, low-cardinality lanes. If you need tenant isolation, do it deliberately.

5) HTTP routes: tie a controller to a pool/lane (bulkhead)

If your “routes” are Symfony HTTP routes, the simplest mapping is:

This bundle supports an opt-in controller docblock tag:

If you omit lane, it defaults to Symfony’s _route value (the route name):

That gives you “bulkheads by route” without needing to manually pass lane strings around.

Pool policy examples (fixed number vs percent vs weighted)

All three pool modes are supported in config:

Notes:

“Sub-lanes” (parent share + child weights)

The underlying bulkhead lane policy is flat (a lane is just a string). There isn’t a first-class “lane hierarchy” in PoolPolicy.

To model “40% of the DB pool is reserved for hydra traffic, and within hydra the charges route is highest priority”, compose two bulkheads:

1) A parent pool that allocates a share of the global budget to a coarse lane (e.g. hydra). 2) A child pool that allocates that share among routes using mode: weighted.

Because this bundle’s controller integration can read multiple @Bulkhead(...) tags, you can acquire both permits per request.

Example (1800 total DB-concurrency, hydra gets ~40% = 720, charges is top priority within hydra):

Controller mapping:

If you want the child lane to default to the Symfony route name, omit lane on the second tag.

6) Retry strategies

You have two different “retry” integration points:

A) Pipeline-stage retries (YAML-friendly)

In pipeline stages, configure a retry stage:

This uses core Gohany\Circuitbreaker\Resilience\RtryRetryMiddleware.

B) Circuit-breaker retries (object-based policies)

If you’re using the core circuit breaker directly (e.g. HTTP circuit breaker services), a recommended approach is to provide retries via your circuit policy by implementing RetrySpecProviderInterface.

See Resources\\config\\services.php in this bundle and vendor\\gohany\\circuitbreaker\\examples.md in the core library for examples.

7) HTTP client: decorate PSR-18

If you have a PSR-18 client (e.g. Symfony’s Psr18Client), you can decorate it with circuit breaking.

For wiring examples, see Resources\\config\\services.php.

8) Multi-circuit requests (layered protection)

Use this when a single request should coordinate multiple circuits, e.g.:

See the “multi-circuit PSR-18 client” example in Resources\\config\\services.php.

9) Observability: emit events to logs/metrics

The core library uses an EmitterInterface (gohany.circuitbreaker.emitter service). Replace it in your app to:

This bundle registers a minimal no-op emitter by default; production apps should replace/decorate it.

10) Storage backends: Redis vs PDO

This bundle’s pool/bulkhead story is Redis-first because it’s designed for multi-process shared capacity.

For circuit breaker state/history stores, the core library supports multiple backends (including Redis and PDO). If you want SQL-backed state/history (auditable, queryable), wire the PDO stores from the core library.

See:

More examples


All versions of circuitbreaker-symfony-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
gohany/circuitbreaker Version v1.1.3
symfony/framework-bundle Version ^5.4 || ^6.0 || ^7.0
symfony/dependency-injection Version ^5.4 || ^6.0 || ^7.0
symfony/config Version ^5.4 || ^6.0 || ^7.0
symfony/console Version ^5.4 || ^6.0 || ^7.0
symfony/http-client-contracts Version ^2.5 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gohany/circuitbreaker-symfony-bundle contains the following files

Loading the files please wait ...