Module: Faulty::Patch::Elasticsearch
- Includes:
- Base
- Defined in:
- lib/faulty/patch/elasticsearch.rb
Overview
Patch Elasticsearch to run requests in a circuit
This module is not required by default
Pass a :faulty
key into your Elasticsearch client options to enable
circuit protection. See circuit_from_hash for the available
options.
By default, all circuit errors raised by this patch inherit from
::Elasticsearch::Transport::Transport::Error
. One side effect of the way
this patch wraps errors is that host_unreachable_exceptions
raised by
the inner transport adapters are converted into
Elasticsearch::Transport::Transport::Error
instead of the transport
error type such as Faraday::ConnectionFailed
.
Defined Under Namespace
Modules: Error, Errors, ServerError, SnifferTimeoutError
Constant Summary collapse
- PATCHED_MODULE =
if Gem.loaded_specs['opensearch-ruby'] require 'opensearch' ::OpenSearch else require 'elasticsearch' ::Elasticsearch end
Instance Method Summary collapse
- #initialize(arguments = {}, &block) ⇒ Object
-
#perform_request(*args) ⇒ Object
Protect all elasticsearch requests.
Methods included from Base
Instance Method Details
#initialize(arguments = {}, &block) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/faulty/patch/elasticsearch.rb', line 72 def initialize(arguments = {}, &block) super errors = [PATCHED_MODULE::Transport::Transport::Error] errors.concat(@transport.host_unreachable_exceptions) @faulty_circuit = Patch.circuit_from_hash( 'elasticsearch', arguments[:faulty], errors: errors, exclude: PATCHED_MODULE::Transport::Transport::Errors::NotFound, patched_error_mapper: ERROR_MAPPER ) end |
#perform_request(*args) ⇒ Object
Protect all elasticsearch requests
88 89 90 |
# File 'lib/faulty/patch/elasticsearch.rb', line 88 def perform_request(*args) faulty_run { super } end |