PHP code example of gohany / circuitbreaker-symfony-bundle
1. Go to this page and download the library: Download gohany/circuitbreaker-symfony-bundle 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/ */
gohany / circuitbreaker-symfony-bundle example snippets
// config/services.php
use Gohany\Circuitbreaker\Util\ExtRedisClient;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
return static function (ContainerConfigurator $c): void {
$services = $c->services();
$services->set('gohany.circuitbreaker.redis_client', ExtRedisClient::class)
->args([service('app.redis')]); // `app.redis` is your \Redis service
};
// services.php
$services->set('gohany.circuitbreaker.redis_client', Gohany\Circuitbreaker\Util\ExtRedisClient::class)
->args([service('app.redis')]); // app.redis is your \Redis service
use Symfony\Component\Routing\Annotation\Route;
final class ChargesController
{
/**
* @Route("/courses/{courseEntity}/hydra/charges", methods={"GET"})
* @Bulkhead(pool="db-main", lane="http.courses.charges")
*/
public function __invoke(): Response
{
// ...
}
}
/**
* @Route("/courses/{courseEntity}/hydra/charges", name="api_courses_hydra_charges", methods={"GET"})
* @Bulkhead(pool="db-main")
*/
public function __invoke(): Response
{
}
use Symfony\Component\Routing\Annotation\Route;
final class ChargesController
{
/**
* @Route("/courses/{courseEntity}/hydra/charges", methods={"GET"})
*
* // Parent share: counts this request against the hydra slice
* @Bulkhead(pool="db-queries", lane="hydra")
*
* // Child weights: counts this request against the hydra route-priority pool
* @Bulkhead(pool="db-hydra", lane="hydra.charges")
*/
public function __invoke(): Response
{
// ...
}
}