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.
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
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/faulty/patch/elasticsearch.rb', line 41 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, patched_error_module: Faulty::Patch::Elasticsearch ) end |
#perform_request(*args) ⇒ Object
Protect all elasticsearch requests
56 57 58 |
# File 'lib/faulty/patch/elasticsearch.rb', line 56 def perform_request(*args) faulty_run { super } end |