-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with circuitbox 2.0.0 #71
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes seem to be as advertised, asked a question with regard to our desired functionality.
@@ -42,7 +42,7 @@ def resource_config | |||
|
|||
def call_with_circuit_if_available | |||
if VertexClient.circuit | |||
VertexClient.circuit.run { yield } | |||
VertexClient.circuit.run(exception: false) { yield } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-checking: we want nil in all failure cases here so that the gem will apply a fallback rate, correct? Or could this potentially amount to silently swallowing invoice or distribute_tax requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct. You added the details around invoice and distribute below.
@@ -46,7 +42,7 @@ | |||
end | |||
end | |||
end | |||
|
|||
it 'does an invoice' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to have a circuit-open test case here just to understand what would happen...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests should cover that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call--I didn't see a distribute tax / circuit open case, but good that we have one for invoice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a distribute tax circuit test.
Looked quickly at what we're doing for invoice and distribute_tax and it seems like the fallback strategy is to raise, so it's good that we'll be notified, but I think the caveat is that iirc invalid quotation requests count against the circuit failure count, so we might end up with an open circuit and operable upstream endpoint. Most invoice and distribute_tax operations are async, I believe, so maybe not an issue as long as we continue to raise. Very important to ensure that we don't return nil, however. There may be some value in omitting the circuit for those operations entirely, and letting exponential backoff handle outage states instead of what feels like a more heavy handed approach with the status quo, but that's probably out of scope for this change. |
@drinks yeah, I agree the circuit setup is not ideal and we could have a variety of false positive circuit failures. Any Savon error will count as a failure. Luckily, I think the failure rate is high enough that, AFAIK, we haven't seen any issues with this during our years of use. |
Stakeholder Overview (learn more)
There were some big breaking changes introduced in
circuitbox
version 2.0 that are affecting the way this gem works with the circuit.circuitbox
version 1.1.1 is incompatible with Ruby 3.X so downgrading is not an option. The most notable changes relevant for this gem are:run
, by default, will raise on failure, where it previously returnednil
. You can pass the argumentexception: false
argument torun
to disable this new default behavior. This is backward compatible with v1.1.1, since theexception
argument is a no-op until v2.0.logger
is deprecated, in favor of using anotifier
.cache
option when initializing a circuit has been renamed tocircuit_store
.reset
method (used in testing) on Circuitbox has been removed.CircuitBreaker
have been changed toattr_reader
, or in some cases removed. This means that the circuit cannot be reconfigured after initialization without a full reset of Circuitbox. I'm not sure this really worked in v1 either, but the attr_accessor's at least gave the illusion that you could reconfigure the circuit.Risk Estimate (learn more)
Changes
run
withrun(exception: false
.reset
with the new way to reset cached circuitbox for circuitbox v2.Updated Dependencies