mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
the previous option was there to allow reconnecting on non-idempotent (i.e. POST) requests, but had the unfortunate side-effect of allowing retries for failures (i.e. timeouts) which had nothing to do with a failed connection error; this mitigates it by enabling retries for ping-aware requests, i.e. if there is an error during PING, always retry
66 lines
1.7 KiB
Plaintext
66 lines
1.7 KiB
Plaintext
module HTTPX
|
|
module Plugins
|
|
module Retries
|
|
MAX_RETRIES: Integer
|
|
IDEMPOTENT_METHODS: Array[String]
|
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
|
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
|
|
|
interface _RetryCallback
|
|
def call: (response response) -> bool?
|
|
end
|
|
|
|
interface _RetriesOptions
|
|
def retry_after: () -> Numeric?
|
|
|
|
def retry_jitter: () -> ^(Numeric jitter) -> Numeric
|
|
|
|
def max_retries: () -> Integer
|
|
|
|
def retry_change_requests: () -> boolish
|
|
|
|
def retry_on: () -> _RetryCallback?
|
|
end
|
|
|
|
def self.extra_options: (Options options) -> retriesOptions
|
|
|
|
module InstanceMethods
|
|
def max_retries: (int) -> instance
|
|
|
|
private
|
|
|
|
def fetch_response: (retriesRequest request, Selector selector, retriesOptions options) -> (retriesResponse | ErrorResponse)?
|
|
|
|
def repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
|
|
|
|
def retryable_error?: (_Exception error) -> bool
|
|
|
|
def try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
|
|
|
|
end
|
|
|
|
module RequestMethods
|
|
@options: Options & _RetriesOptions
|
|
|
|
attr_accessor retries: Integer
|
|
|
|
attr_writer partial_response: Response?
|
|
|
|
def response=: (retriesResponse | ErrorResponse response) -> void
|
|
end
|
|
|
|
module ResponseMethods
|
|
def from_partial_response: (Response response) -> void
|
|
end
|
|
|
|
type retriesOptions = Options & _RetriesOptions
|
|
|
|
type retriesRequest = Request & RequestMethods
|
|
|
|
type retriesResponse = Response & ResponseMethods
|
|
end
|
|
|
|
type sessionRetries = Session & Retries::InstanceMethods
|
|
end
|
|
end
|