Module: JayAPI::Elasticsearch::Mixins::RetriableRequests

Included in:
Client, Tasks
Defined in:
lib/jay_api/elasticsearch/mixins/retriable_requests.rb

Overview

A mixin that allows the including class to retry requests to Elasticsearch by leveraging the Abstract::Connection class’ capabilities.

Constant Summary collapse

RETRIABLE_ERRORS =

The errors that, if raised, must cause a retry of the connection.

[
  ::Elasticsearch::Transport::Transport::ServerError,
  Faraday::TimeoutError
].freeze
NON_RETRIABLE_ERRORS =

Subclasses of the Elasticsearch::Transport::Transport::ServerError for which a retry doesn’t make sense.

[
  ::Elasticsearch::Transport::Transport::Errors::BadRequest,
  ::Elasticsearch::Transport::Transport::Errors::Unauthorized,
  ::Elasticsearch::Transport::Transport::Errors::Forbidden,
  ::Elasticsearch::Transport::Transport::Errors::NotFound,
  ::Elasticsearch::Transport::Transport::Errors::MethodNotAllowed,
  ::Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge,
  ::Elasticsearch::Transport::Transport::Errors::NotImplemented
].freeze

Instance Method Summary collapse

Instance Method Details

#loggerLogging::Logger

Returns A logger to log messages.

Returns:

  • (Logging::Logger)

    A logger to log messages.



45
46
47
# File 'lib/jay_api/elasticsearch/mixins/retriable_requests.rb', line 45

def logger
  raise_not_implemented(__method__)
end

#max_attemptsInteger

Returns The maximum number of times a request should be retried before giving up.

Returns:

  • (Integer)

    The maximum number of times a request should be retried before giving up.



34
35
36
# File 'lib/jay_api/elasticsearch/mixins/retriable_requests.rb', line 34

def max_attempts
  raise_not_implemented(__method__)
end

#non_retriable_errorsArray<Class>

Returns An array of subclasses of the Elasticsearch::Transport::Transport::ServerError for which a retry doesn’t make sense.

Returns:

  • (Array<Class>)

    An array of subclasses of the Elasticsearch::Transport::Transport::ServerError for which a retry doesn’t make sense.



58
59
60
# File 'lib/jay_api/elasticsearch/mixins/retriable_requests.rb', line 58

def non_retriable_errors
  NON_RETRIABLE_ERRORS
end

#retriable_errorsArray<Class>

Returns The array of errors that, if raised, must cause a retry of the request.

Returns:

  • (Array<Class>)

    The array of errors that, if raised, must cause a retry of the request.



51
52
53
# File 'lib/jay_api/elasticsearch/mixins/retriable_requests.rb', line 51

def retriable_errors
  RETRIABLE_ERRORS
end

#wait_strategyJayAPI::Elasticsearch::WaitStrategy

Returns The waiting strategy for retries.

Returns:

  • (JayAPI::Elasticsearch::WaitStrategy)

    The waiting strategy for retries.



40
41
42
# File 'lib/jay_api/elasticsearch/mixins/retriable_requests.rb', line 40

def wait_strategy
  raise_not_implemented(__method__)
end