Conversation
lib/record_store/provider.rb
Outdated
| max_conn_resets -= 1 | ||
|
|
||
| waiter.wait | ||
| rescue RecordStore::Provider::Error => e |
There was a problem hiding this comment.
instead of using the if match, can we raise/rescue a more specific error?
There was a problem hiding this comment.
I'm a bit surprised this retry is at the generic provider level instead of Cloudflare-specific
do other providers have their retry logic built in?
There was a problem hiding this comment.
I suggest creating a new error type like RetryableError and raising that from the provider itself with logic in the provider to switch between the current Error and new RetryableError based on the failure scenario
b22f985 to
2727ef6
Compare
|
|
||
| begin | ||
| response = conn.request(request) | ||
| if response.is_a?(Net::HTTPRetriableError) |
There was a problem hiding this comment.
Looked up the spec, it seems like only 3XX errors fit this
There was a problem hiding this comment.
Good catch, thank you. I've updated the PR body explaining the fix.
2d1d969 to
18bcd8f
Compare
18bcd8f to
e413225
Compare
| if response.is_a?(Net::HTTPRedirection) || response.is_a?(Net::HTTPServerError) | ||
| response.error! | ||
| end |
There was a problem hiding this comment.
Why are we only raising for 3XX and 5XX?
There was a problem hiding this comment.
fixed to use response.value
# Raises an HTTP error if the response is not 2xx (success).
def value
error! unless self.kind_of?(Net::HTTPSuccess)
end
Logical flow:
retry_on_connection_errorsin provider base class now checks forRecordStore::Provider::RetriableErrorRetriableErrorup to provider implementationsresponse.is_a?(Net::HTTPServerError)and catchesNet::HTTPFatalErrorand raisesRetriableError; also checks for 3xx response and catchesNet::HTTPRetriableErrorTests moved to focus on Cloudflare client's use of retries
RetriableError