yammer / circuitbox

Circuit breaker built with large Ruby apps in mind.
Other
704 stars 59 forks source link

add Circuitbox.open? method to check if a given service's circuit is open #175

Closed chrisplim closed 3 years ago

chrisplim commented 3 years ago

Adds a method to check if a given service name has a circuit and it's open. This makes it easier to check if a circuit is open.

matthewshafer commented 3 years ago

My initial feeling with adding an open? method to Circuitbox is one of a little confusion. It would be reasonable to think that the open? method would give me the status of every circuit that's been created, but it only checks the status of ones created through Circuitbox.circuit.

Currently the way the circuit open status could be checked would be to call open? on the return value of Circuitbox.circuit as long as a block is not passed to Circuitbox.circuit.

chrisplim commented 3 years ago

Isn't the recommended way to create a circuit through Circuitbox.circuit, so one can check if the circuit already exists for a service name. I was hoping that we can use this method as an easier means to check if a circuit is open like

Circuitbox.open?('service_name')

instead of

circuit = Circuitbox.circuit('service_name', options)
circuit.open?