{"id":13665691,"url":"https://github.com/wsargent/circuit_breaker","last_synced_at":"2025-10-06T01:08:04.145Z","repository":{"id":611911,"uuid":"249760","full_name":"wsargent/circuit_breaker","owner":"wsargent","description":"Implementation of Michael Nygard's Circuit Breaker pattern in Ruby","archived":false,"fork":false,"pushed_at":"2020-04-11T20:01:13.000Z","size":45,"stargazers_count":404,"open_issues_count":2,"forks_count":36,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-09T10:08:49.139Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rdoc.info/projects/wsargent/circuit_breaker","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Unknwon/go-fundamental-programming","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wsargent.png","metadata":{"files":{"readme":"README.md","changelog":"History.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-07-13T06:18:43.000Z","updated_at":"2025-03-23T12:08:51.000Z","dependencies_parsed_at":"2022-07-05T03:30:42.112Z","dependency_job_id":null,"html_url":"https://github.com/wsargent/circuit_breaker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsargent%2Fcircuit_breaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsargent%2Fcircuit_breaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsargent%2Fcircuit_breaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsargent%2Fcircuit_breaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wsargent","download_url":"https://codeload.github.com/wsargent/circuit_breaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-02T06:00:47.563Z","updated_at":"2025-10-06T01:07:59.070Z","avatar_url":"https://github.com/wsargent.png","language":"Ruby","funding_links":[],"categories":["1. language"],"sub_categories":["1.1 ruby"],"readme":"# circuit_breaker\n\n* http://github.com/wsargent/circuit_breaker\n* http://rdoc.info/projects/wsargent/circuit_breaker\n* Will Sargent \u003cwill.sargent@gmail.com\u003e\n\n## DESCRIPTION:\n\nCircuitBreaker is a relatively simple Ruby mixin that will wrap\na call to a given service in a circuit breaker pattern.\n\nThe circuit starts off \"closed\" meaning that all calls will go through.\nHowever, consecutive failures are recorded and after a threshold is reached,\nthe circuit will \"trip\", setting the circuit into an \"open\" state.\n\nIn an \"open\" state, every call to the service will fail by raising\nCircuitBrokenException.\n\nThe circuit will remain in an \"open\" state until the failure timeout has\nelapsed.\n\nAfter the failure_timeout has elapsed, the circuit will go into\na \"half open\" state and the call will go through.  A failure will\nimmediately pop the circuit open again, and a success will close the\ncircuit and reset the failure count.\n\nFor services that can take an unmanagable amount of time to respond an\ninvocation timeout threshold is provided.  If the service fails to return\nbefore the invocation_timeout duration has passed, the circuit will \"trip\",\nsetting the circuit into an \"open\" state.\n```rb\nrequire 'circuit_breaker'\nclass TestService\n  include CircuitBreaker\n\n  def call_remote_service() ...\n\n  circuit_method :call_remote_service\n\n  # Optional\n  circuit_handler do |handler|\n    handler.logger = Logger.new(STDOUT)\n    handler.failure_threshold = 5\n    handler.failure_timeout = 5\n    handler.invocation_timeout = 10\n    handler.excluded_exceptions = [NotConsideredFailureException]\n  end\n\n  # Optional\n  circuit_handler_class MyCustomCircuitHandler\nend\n```\n\n## FEATURES/PROBLEMS:\n\n* Can run out of the box with minimal dependencies and a couple of lines of code.\n* Easy to extend: add your own circuit breakers or states or extend the existing ones.\n* Does not currently handle static class methods.\n\n## SYNOPSIS:\n\nAn implementation of Michael Nygard's Circuit Breaker pattern.\n\n## REQUIREMENTS:\n\ncircuit_breaker has a dependency on AASM @ http://github.com/rubyist/aasm/tree/master\n\n## INSTALL:\n\n* gem install circuit_breaker\n\n## LICENSE:\n\nCopyright (c) 2016, Will Sargent\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the\nfollowing conditions are met:\n\n  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following\n    disclaimer.\n  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following\n    disclaimer in the documentation and/or other materials provided with the distribution.\n  * The names of its contributors may not be used to endorse or promote products derived from this software without\n    specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE\nUSE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsargent%2Fcircuit_breaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwsargent%2Fcircuit_breaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsargent%2Fcircuit_breaker/lists"}