faulty 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c98e42a6c19d8832dc0267abba5498f0203922bd98cb3bb1b9c28643c9a9f3f
4
- data.tar.gz: 7b68f35acfa54c10ec411d26eb45319eb47bf6d688d447adaead117f1ec098ab
3
+ metadata.gz: 2eda80b5d7aba5948835addf9b8cf418aba0e8ba48453361678a15229ea4481a
4
+ data.tar.gz: 53a27be99ae42c157be28df1e887033b86a53ccd232b05bc290bf511ac4e9d0c
5
5
  SHA512:
6
- metadata.gz: 2677b6450704cbabd6b9c9e3c5d68bad7b762810f27f0b0a9171bca825051c9668aff54aadb58b73884a266f5c0fdfaa46f57d56bc0a6d93824bb1d02c4c08fd
7
- data.tar.gz: ef98388e2d161b8995310de758b11ddc960a2b0b4c05605ba9cf7e30334c36bb8590578259c0e0158516254fb56d9bc1bb5cb2f42cea88c8224c176301535898
6
+ metadata.gz: 766ab386706d842f4f02faa572d931b702b532071baa221f5c77c1330e3086cab1f2126f548c255254fe3d4f85ca9666698116b808c0b0e29c507ee5f6680c5c
7
+ data.tar.gz: c5f04aa84ad450ae186c57236d80bb872c4977e60930a0f99e876bf497aa2473c2753d2307634b1cfe0dc332ce1d3c88382281ce2158c13cf140e432afaeb97e
data/CHANGELOG.md CHANGED
@@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
  [Unreleased]
10
10
  -------------------
11
11
 
12
+ [0.10.0] - 2023-04-05
13
+ ---------------------
14
+
15
+ ### Added
16
+
17
+ * Support the opensearch-ruby gem #65 justinhoward
18
+
19
+ ### Changed
20
+
21
+ * Split CI tasks into their own jobs #64 justinhoward
22
+
12
23
  [0.9.0] - 2022-08-18
13
24
  ---------------------
14
25
 
@@ -289,7 +300,8 @@ of AutoWire.
289
300
 
290
301
  Initial public release
291
302
 
292
- [Unreleased]: https://github.com/ParentSquare/faulty/compare/v0.9.0...HEAD
303
+ [Unreleased]: https://github.com/ParentSquare/faulty/compare/v0.10.0...HEAD
304
+ [0.10.0]: https://github.com/ParentSquare/faulty/compare/v0.9.0...v0.10.0
293
305
  [0.9.0]: https://github.com/ParentSquare/faulty/compare/v0.8.7...v0.9.0
294
306
  [0.8.7]: https://github.com/ParentSquare/faulty/compare/v0.8.6...v0.8.7
295
307
  [0.8.6]: https://github.com/ParentSquare/faulty/compare/v0.8.5...v0.8.6
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'elasticsearch'
4
-
5
3
  class Faulty
6
4
  module Patch
7
5
  # Patch Elasticsearch to run requests in a circuit
@@ -40,15 +38,23 @@ class Faulty
40
38
  module SnifferTimeoutError; end
41
39
  module ServerError; end
42
40
 
41
+ PATCHED_MODULE = if Gem.loaded_specs['opensearch-ruby']
42
+ require 'opensearch'
43
+ ::OpenSearch
44
+ else
45
+ require 'elasticsearch'
46
+ ::Elasticsearch
47
+ end
48
+
43
49
  # We will freeze this after adding the dynamic error classes
44
50
  MAPPED_ERRORS = { # rubocop:disable Style/MutableConstant
45
- ::Elasticsearch::Transport::Transport::Error => Error,
46
- ::Elasticsearch::Transport::Transport::SnifferTimeoutError => SnifferTimeoutError,
47
- ::Elasticsearch::Transport::Transport::ServerError => ServerError
51
+ PATCHED_MODULE::Transport::Transport::Error => Error,
52
+ PATCHED_MODULE::Transport::Transport::SnifferTimeoutError => SnifferTimeoutError,
53
+ PATCHED_MODULE::Transport::Transport::ServerError => ServerError
48
54
  }
49
55
 
50
56
  module Errors
51
- ::Elasticsearch::Transport::Transport::ERRORS.each do |_code, klass|
57
+ PATCHED_MODULE::Transport::Transport::ERRORS.each do |_code, klass|
52
58
  MAPPED_ERRORS[klass] = const_set(klass.name.split('::').last, Module.new)
53
59
  end
54
60
  end
@@ -66,14 +72,14 @@ class Faulty
66
72
  def initialize(arguments = {}, &block)
67
73
  super
68
74
 
69
- errors = [::Elasticsearch::Transport::Transport::Error]
75
+ errors = [PATCHED_MODULE::Transport::Transport::Error]
70
76
  errors.concat(@transport.host_unreachable_exceptions)
71
77
 
72
78
  @faulty_circuit = Patch.circuit_from_hash(
73
79
  'elasticsearch',
74
80
  arguments[:faulty],
75
81
  errors: errors,
76
- exclude: ::Elasticsearch::Transport::Transport::Errors::NotFound,
82
+ exclude: PATCHED_MODULE::Transport::Transport::Errors::NotFound,
77
83
  patched_error_mapper: ERROR_MAPPER
78
84
  )
79
85
  end
@@ -86,10 +92,20 @@ class Faulty
86
92
  end
87
93
  end
88
94
 
89
- module Elasticsearch
90
- module Transport
91
- class Client
92
- prepend(Faulty::Patch::Elasticsearch)
95
+ if Gem.loaded_specs['opensearch-ruby']
96
+ module OpenSearch
97
+ module Transport
98
+ class Client
99
+ prepend(Faulty::Patch::Elasticsearch)
100
+ end
101
+ end
102
+ end
103
+ else
104
+ module Elasticsearch
105
+ module Transport
106
+ class Client
107
+ prepend(Faulty::Patch::Elasticsearch)
108
+ end
93
109
  end
94
110
  end
95
111
  end
@@ -3,6 +3,6 @@
3
3
  class Faulty
4
4
  # The current Faulty version
5
5
  def self.version
6
- Gem::Version.new('0.9.0')
6
+ Gem::Version.new('0.10.0')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faulty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2023-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -150,7 +150,7 @@ licenses:
150
150
  metadata:
151
151
  rubygems_mfa_required: 'true'
152
152
  changelog_uri: https://github.com/ParentSquare/faulty/blob/master/CHANGELOG.md
153
- documentation_uri: https://www.rubydoc.info/gems/faulty/0.9.0
153
+ documentation_uri: https://www.rubydoc.info/gems/faulty/0.10.0
154
154
  post_install_message:
155
155
  rdoc_options: []
156
156
  require_paths:
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
- rubygems_version: 3.1.2
169
+ rubygems_version: 3.3.5
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Fault-tolerance tools for ruby based on circuit-breakers