faulty 0.7.1 → 0.7.2
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/CHANGELOG.md +6 -1
- data/README.md +16 -0
- data/lib/faulty/cache/circuit_proxy.rb +1 -1
- data/lib/faulty/circuit.rb +2 -0
- data/lib/faulty/events/filter_notifier.rb +31 -0
- data/lib/faulty/events.rb +1 -0
- data/lib/faulty/storage/circuit_proxy.rb +1 -1
- data/lib/faulty/storage/null.rb +83 -0
- data/lib/faulty/storage.rb +1 -0
- data/lib/faulty/version.rb +1 -1
- data/lib/faulty.rb +27 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d963d5c58861cc9e39c3222b5dc78a2a537c15fc10e0ed76d9d5b41a6704356b
|
4
|
+
data.tar.gz: e31811fc1b5be36975982e966106ea7f323b4e334b87cfaca85667f550245584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52aae6a3997fca7d38aebd124399747ee21a687114076e5d73c135d86ab147360e71a9f7a95ee4a5f548b6709089697e77fa472730c3fc18cb9c1d412bdac4ca
|
7
|
+
data.tar.gz: 56b02cad8fe96373c916746bfc7c6f83665a74e7a3771d7b761244373b1d4b79aeb44d94fbe9401f82f8671b4e21c625a079b4845a42565dfbfbdfd37a07d2bf
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
## Release v0.7.2
|
2
|
+
|
3
|
+
* Add Faulty.disable! for disabling globally #38 justinhoward
|
4
|
+
* Suppress circuit_success for proxy circuits #39 justinhoward
|
5
|
+
|
1
6
|
## Release v0.7.1
|
2
7
|
|
3
|
-
|
8
|
+
* Fix success event crash in log listener #37 justinhoward
|
4
9
|
|
5
10
|
## Release v0.7.0
|
6
11
|
|
data/README.md
CHANGED
@@ -88,6 +88,7 @@ Also see "Release It!: Design and Deploy Production-Ready Software" by
|
|
88
88
|
+ [CallbackListener](#callbacklistener)
|
89
89
|
+ [Other Built-in Listeners](#other-built-in-listeners)
|
90
90
|
+ [Custom Listeners](#custom-listeners)
|
91
|
+
* [Disabling Faulty Globally](#disabling-faulty-globally)
|
91
92
|
* [How it Works](#how-it-works)
|
92
93
|
+ [Caching](#caching)
|
93
94
|
+ [Fault Tolerance](#fault-tolerance)
|
@@ -1124,6 +1125,21 @@ Faulty.init do |config|
|
|
1124
1125
|
end
|
1125
1126
|
```
|
1126
1127
|
|
1128
|
+
## Disabling Faulty Globally
|
1129
|
+
|
1130
|
+
For testing or for some environments, you may wish to disable Faulty circuits
|
1131
|
+
at a global level.
|
1132
|
+
|
1133
|
+
```ruby
|
1134
|
+
Faulty.disable!
|
1135
|
+
```
|
1136
|
+
|
1137
|
+
This only affects the process where you run the `#disable!` method and it does
|
1138
|
+
not affect the stored state of circuits.
|
1139
|
+
|
1140
|
+
Faulty will **still use the cache** even when disabled. If you also want to
|
1141
|
+
disable the cache, configure Faulty to use a `Faulty::Cache::Null` cache.
|
1142
|
+
|
1127
1143
|
## How it Works
|
1128
1144
|
|
1129
1145
|
Faulty implements a version of circuit breakers inspired by "Release It!: Design
|
data/lib/faulty/circuit.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Faulty
|
4
|
+
module Events
|
5
|
+
# Wraps a Notifier and filters events by name
|
6
|
+
class FilterNotifier
|
7
|
+
# @param notifier [Notifier] The internal notifier to filter events for
|
8
|
+
# @param events [Array, nil] An array of events to allow. If nil, all
|
9
|
+
# {EVENTS} will be used
|
10
|
+
# @param exclude [Array, nil] An array of events to disallow. If nil,
|
11
|
+
# no events will be disallowed. Takes priority over `events`.
|
12
|
+
def initialize(notifier, events: nil, exclude: nil)
|
13
|
+
@notifier = notifier
|
14
|
+
@events = Set.new(events || EVENTS)
|
15
|
+
exclude&.each { |e| @events.delete(e) }
|
16
|
+
end
|
17
|
+
|
18
|
+
# Notify all listeners of an event
|
19
|
+
#
|
20
|
+
# If a listener raises an error while handling an event, that error will
|
21
|
+
# be captured and written to STDERR.
|
22
|
+
#
|
23
|
+
# @param (see Notifier)
|
24
|
+
def notify(event, payload)
|
25
|
+
return unless @events.include?(event)
|
26
|
+
|
27
|
+
@notifier.notify(event, payload)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/faulty/events.rb
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Faulty
|
4
|
+
module Storage
|
5
|
+
# A no-op backend for disabling circuits
|
6
|
+
class Null
|
7
|
+
# Define a single global instance
|
8
|
+
@instance = new
|
9
|
+
|
10
|
+
def self.new
|
11
|
+
@instance
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param (see Interface#entry)
|
15
|
+
# @return (see Interface#entry)
|
16
|
+
def entry(_circuit, _time, _success)
|
17
|
+
[]
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param (see Interface#open)
|
21
|
+
# @return (see Interface#open)
|
22
|
+
def open(_circuit, _opened_at)
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param (see Interface#reopen)
|
27
|
+
# @return (see Interface#reopen)
|
28
|
+
def reopen(_circuit, _opened_at, _previous_opened_at)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param (see Interface#close)
|
33
|
+
# @return (see Interface#close)
|
34
|
+
def close(_circuit)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param (see Interface#lock)
|
39
|
+
# @return (see Interface#lock)
|
40
|
+
def lock(_circuit, _state)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param (see Interface#unlock)
|
44
|
+
# @return (see Interface#unlock)
|
45
|
+
def unlock(_circuit)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param (see Interface#reset)
|
49
|
+
# @return (see Interface#reset)
|
50
|
+
def reset(_circuit)
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param (see Interface#status)
|
54
|
+
# @return (see Interface#status)
|
55
|
+
def status(circuit)
|
56
|
+
Faulty::Status.new(
|
57
|
+
options: circuit.options,
|
58
|
+
stub: true
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
# @param (see Interface#history)
|
63
|
+
# @return (see Interface#history)
|
64
|
+
def history(_circuit)
|
65
|
+
[]
|
66
|
+
end
|
67
|
+
|
68
|
+
# @param (see Interface#list)
|
69
|
+
# @return (see Interface#list)
|
70
|
+
def list
|
71
|
+
[]
|
72
|
+
end
|
73
|
+
|
74
|
+
# This backend is fault tolerant
|
75
|
+
#
|
76
|
+
# @param (see Interface#fault_tolerant?)
|
77
|
+
# @return (see Interface#fault_tolerant?)
|
78
|
+
def fault_tolerant?
|
79
|
+
true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/faulty/storage.rb
CHANGED
@@ -10,5 +10,6 @@ require 'faulty/storage/auto_wire'
|
|
10
10
|
require 'faulty/storage/circuit_proxy'
|
11
11
|
require 'faulty/storage/fallback_chain'
|
12
12
|
require 'faulty/storage/fault_tolerant_proxy'
|
13
|
+
require 'faulty/storage/null'
|
13
14
|
require 'faulty/storage/memory'
|
14
15
|
require 'faulty/storage/redis'
|
data/lib/faulty/version.rb
CHANGED
data/lib/faulty.rb
CHANGED
@@ -128,6 +128,33 @@ class Faulty
|
|
128
128
|
def current_time
|
129
129
|
Time.now.to_i
|
130
130
|
end
|
131
|
+
|
132
|
+
# Disable Faulty circuits
|
133
|
+
#
|
134
|
+
# This allows circuits to run as if they were always closed. Does
|
135
|
+
# not disable caching.
|
136
|
+
#
|
137
|
+
# Intended for use in tests, or to disable Faulty entirely for an
|
138
|
+
# environment.
|
139
|
+
#
|
140
|
+
# @return [void]
|
141
|
+
def disable!
|
142
|
+
@disabled = true
|
143
|
+
end
|
144
|
+
|
145
|
+
# Re-enable Faulty if disabled with {#disable!}
|
146
|
+
#
|
147
|
+
# @return [void]
|
148
|
+
def enable!
|
149
|
+
@disabled = false
|
150
|
+
end
|
151
|
+
|
152
|
+
# Check whether Faulty was disabled with {#disable!}
|
153
|
+
#
|
154
|
+
# @return [Boolean] True if disabled
|
155
|
+
def disabled?
|
156
|
+
@disabled == true
|
157
|
+
end
|
131
158
|
end
|
132
159
|
|
133
160
|
attr_reader :options
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faulty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Howard
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/faulty/error.rb
|
148
148
|
- lib/faulty/events.rb
|
149
149
|
- lib/faulty/events/callback_listener.rb
|
150
|
+
- lib/faulty/events/filter_notifier.rb
|
150
151
|
- lib/faulty/events/honeybadger_listener.rb
|
151
152
|
- lib/faulty/events/listener_interface.rb
|
152
153
|
- lib/faulty/events/log_listener.rb
|
@@ -165,6 +166,7 @@ files:
|
|
165
166
|
- lib/faulty/storage/fault_tolerant_proxy.rb
|
166
167
|
- lib/faulty/storage/interface.rb
|
167
168
|
- lib/faulty/storage/memory.rb
|
169
|
+
- lib/faulty/storage/null.rb
|
168
170
|
- lib/faulty/storage/redis.rb
|
169
171
|
- lib/faulty/version.rb
|
170
172
|
homepage: https://github.com/ParentSquare/faulty
|