Module: Faulty::Patch::Elasticsearch
- Includes:
- Base
- Included in:
- Elasticsearch::Transport::Client
- 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
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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/faulty/patch/elasticsearch.rb', line 66 def initialize(arguments = {}, &block) super errors = [::Elasticsearch::Transport::Transport::Error] errors.concat(@transport.host_unreachable_exceptions) @faulty_circuit = Patch.circuit_from_hash( 'elasticsearch', arguments[:faulty], errors: errors, exclude: ::Elasticsearch::Transport::Transport::Errors::NotFound, patched_error_mapper: ERROR_MAPPER ) end |
#perform_request(*args) ⇒ Object
Protect all elasticsearch requests
82 83 84 |
# File 'lib/faulty/patch/elasticsearch.rb', line 82 def perform_request(*args) faulty_run { super } end |