{"id":19218777,"url":"https://github.com/fadilxcoder/circuit-breaker","last_synced_at":"2026-04-20T19:32:30.866Z","repository":{"id":86245141,"uuid":"556715002","full_name":"fadilxcoder/circuit-breaker","owner":"fadilxcoder","description":"HFX - Circuit Breaker (Cache mechanism)","archived":false,"fork":false,"pushed_at":"2022-10-24T11:30:25.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T09:14:52.454Z","etag":null,"topics":["circuit-breaker","notes","php","poc","project","redis"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fadilxcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-24T11:30:03.000Z","updated_at":"2022-10-24T11:33:39.000Z","dependencies_parsed_at":"2023-03-08T10:00:36.205Z","dependency_job_id":null,"html_url":"https://github.com/fadilxcoder/circuit-breaker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fadilxcoder/circuit-breaker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fcircuit-breaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fcircuit-breaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fcircuit-breaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fcircuit-breaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fadilxcoder","download_url":"https://codeload.github.com/fadilxcoder/circuit-breaker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fadilxcoder%2Fcircuit-breaker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32062390,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circuit-breaker","notes","php","poc","project","redis"],"created_at":"2024-11-09T14:28:02.913Z","updated_at":"2026-04-20T19:32:30.850Z","avatar_url":"https://github.com/fadilxcoder.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Notes \n\n- https://github.com/DeGraciaMathieu/php-easy-breaker (PHP implementation of circuit breaker pattern)\n- Integrate codebase in project itself **without** using composer\n\n```php\n\nrequire __DIR__.'/vendor/autoload.php';\n\nuse Exception;\nuse DeGraciaMathieu\\EasyBreaker\\Breaker;\nuse DeGraciaMathieu\\EasyBreaker\\CircuitBreaker;\n\n$firstBreaker = (new Breaker)\n    -\u003ewhen(Exception::class)\n    -\u003edo(function(Exception $e){\n        return \"it's broken.\";\n    });\n\n$secondBreaker = (new Breaker)\n    -\u003ewhen(Exception::class)\n    -\u003edo(function(Exception $e){\n        return \"really broken.\";\n    });\n\n$thirdBreaker = (new Breaker)\n    -\u003ewhen(AnotherException::class)\n    -\u003edo(function(AnotherException $e){\n        return \"boom.\";\n    });\n\n$results = (new CircuitBreaker())\n    -\u003eaddBreaker($firstBreaker)\n    -\u003eaddBreaker($secondBreaker)\n    -\u003eaddBreaker($thirdBreaker)\n    -\u003eclosure(function(){\n        throw new Exception();\n    });\n\nvar_dump($results);\n\n// array(2) {\n//   [0]=\u003e\n//   string(12) \"it's broken.\"\n//   [1]=\u003e\n//   string(18) \"really broken.\"\n// }\n\n```\n\n**Actual Code**\n\n```php\n\nclass ContentController extends Controller\n{\n    public function show(Request $request, UsersRepository $usersRepository)\n    {\n        $users = null;\n        $flag = false;\n        $key = ['hfx', 'circuit-breaker', 'users'];\n\n        try {\n            $users = $usersRepository-\u003egetUsers();\n            Redis::set($key, $users);\n        } catch (Exception $e) {\n            $flag = true;\n        }\n        \n        if ($flag) {\n            $cacheUserCircuitBreaker = (new Breaker)\n                -\u003ewhen(UsersNotFound::class)\n                -\u003edo(function() use ($key) {\n                    return Redis::get($key);\n                });\n\n            $results = (new CircuitBreaker())\n                -\u003eaddBreaker($cacheUserCircuitBreaker)\n                -\u003eclosure(function(){\n                    throw new UsersNotFound();\n                });\n            dump('Exception raised to activate(flag) circuit breaker !');\n            $users = $results[0];\n        }\n        \n        return $this-\u003erender('content/index.html.twig', [\n            'users' =\u003e $users\n        ]);\n    }\n}\n\n```\n\n```php\n\nclass UsersRepository extends Repository\n{\n    public function getUsers()\n    {\n        // throw new \\Exception(); # \u003c-- Raise exception to activate circuit breaker\n\n        $query = '\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffadilxcoder%2Fcircuit-breaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffadilxcoder%2Fcircuit-breaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffadilxcoder%2Fcircuit-breaker/lists"}