noiseless 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/noiseless/adapters/execution_modules/http_transport.rb +12 -0
- data/lib/noiseless/callbacks.rb +4 -4
- data/lib/noiseless/version.rb +1 -1
- data/lib/noiseless.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a2c76e38f11ce0e3d82ecea5c3644022e1b793613e413f81987063e333da393
|
|
4
|
+
data.tar.gz: 7b862a6892326ed2fff34d3aa087d2cdfeafbc1b007b5f5c6285286d12d26a4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d25d6a3a8fd986c7f99454f358da6abe29a7c64ee4beddab5925a83c580469625dfc20bf6b19e6ca6af0448ea87093d05275b24ef23d7b4b9b17edc93ceec9a4
|
|
7
|
+
data.tar.gz: 61371d2765af21a3d689931abe71afe4b13942fe4b6c7621115b0d75b1ce0a4d249b28f7ffb40a66e1ab28d5da57f65d3d8814e62372bd13c05c74885cd26507
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "socket"
|
|
4
|
+
require "timeout"
|
|
5
|
+
|
|
3
6
|
module Noiseless
|
|
4
7
|
module Adapters
|
|
5
8
|
module ExecutionModules
|
|
6
9
|
# Shared Async::HTTP connection handling for HTTP-based adapters.
|
|
7
10
|
# Host classes must provide a private +default_port+ method.
|
|
8
11
|
module HttpTransport
|
|
12
|
+
# Low-level failures the Async::HTTP stack raises when it cannot
|
|
13
|
+
# complete a round-trip with the backend (refused/reset connection,
|
|
14
|
+
# DNS failure, transport timeout). These are wrapped into
|
|
15
|
+
# Noiseless::ConnectionError so callers never have to know which HTTP
|
|
16
|
+
# stack is underneath.
|
|
17
|
+
TRANSPORT_ERRORS = [SystemCallError, SocketError, IOError, Timeout::Error].freeze
|
|
9
18
|
def initialize(hosts: [], **connection_params)
|
|
10
19
|
# Ensure we always have at least one host
|
|
11
20
|
hosts_array = Array(hosts)
|
|
@@ -69,6 +78,9 @@ module Noiseless
|
|
|
69
78
|
client = @clients[host]
|
|
70
79
|
|
|
71
80
|
yield(client)
|
|
81
|
+
rescue *TRANSPORT_ERRORS => e
|
|
82
|
+
raise Noiseless::ConnectionError,
|
|
83
|
+
"search backend unreachable at #{host} (#{e.class}: #{e.message})"
|
|
72
84
|
end
|
|
73
85
|
|
|
74
86
|
def default_headers
|
data/lib/noiseless/callbacks.rb
CHANGED
|
@@ -54,7 +54,7 @@ module Noiseless
|
|
|
54
54
|
return unless should_update_search_index?
|
|
55
55
|
|
|
56
56
|
update_search_index_async if noiseless_new_record? || (respond_to?(:changed?) && changed?)
|
|
57
|
-
rescue
|
|
57
|
+
rescue Noiseless::Error => e
|
|
58
58
|
handle_search_index_error(e, :update)
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ module Noiseless
|
|
|
62
62
|
return unless should_update_search_index?
|
|
63
63
|
|
|
64
64
|
update_search_index_async
|
|
65
|
-
rescue
|
|
65
|
+
rescue Noiseless::Error => e
|
|
66
66
|
handle_search_index_error(e, :update)
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -70,7 +70,7 @@ module Noiseless
|
|
|
70
70
|
return unless should_update_search_index?
|
|
71
71
|
|
|
72
72
|
remove_from_search_index_async
|
|
73
|
-
rescue
|
|
73
|
+
rescue Noiseless::Error => e
|
|
74
74
|
handle_search_index_error(e, :delete)
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ module Noiseless
|
|
|
78
78
|
return unless should_update_search_index?
|
|
79
79
|
|
|
80
80
|
remove_from_search_index_async
|
|
81
|
-
rescue
|
|
81
|
+
rescue Noiseless::Error => e
|
|
82
82
|
handle_search_index_error(e, :delete)
|
|
83
83
|
end
|
|
84
84
|
|
data/lib/noiseless/version.rb
CHANGED
data/lib/noiseless.rb
CHANGED
|
@@ -32,6 +32,14 @@ module Noiseless
|
|
|
32
32
|
# (malformed query, missing index, shard failures).
|
|
33
33
|
class SearchError < RequestError; end
|
|
34
34
|
|
|
35
|
+
# Raised when the search backend cannot be reached at all: connection
|
|
36
|
+
# refused, DNS failure, reset socket, or transport timeout. Distinct from
|
|
37
|
+
# RequestError, which means the backend *was* reached and replied with an
|
|
38
|
+
# HTTP error. Wrapping happens at the transport boundary (HttpTransport),
|
|
39
|
+
# so callers rescue Noiseless::Error instead of enumerating socket/system
|
|
40
|
+
# exception classes from whatever HTTP stack the transport happens to use.
|
|
41
|
+
class ConnectionError < Error; end
|
|
42
|
+
|
|
35
43
|
class Configuration
|
|
36
44
|
attr_accessor :connections_config, :default_connection, :default_adapter, :config_path
|
|
37
45
|
|