Skip to content

Commit

Permalink
Remove features deprecated in 0.8.5
Browse files Browse the repository at this point in the history
* The 3 argument form of `Storage::Interface#entry` deprecated in 0.8.5 is now
  removed.
* The `error_module` circuit option deprecated in 0.8.5 is now removed.
  • Loading branch information
justinhoward committed Aug 19, 2022
1 parent eb4b0b9 commit 8dc026a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 57 deletions.
41 changes: 2 additions & 39 deletions lib/faulty/circuit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class Circuit
:sample_threshold,
:errors,
:error_mapper,
:error_module,
:exclude,
:cache,
:notifier,
Expand Down Expand Up @@ -158,17 +157,6 @@ def finalize
unless cache_refreshes_after.nil?
self.cache_refresh_jitter = 0.2 * cache_refreshes_after
end

deprecated_error_module
end

private

def deprecated_error_module
return unless error_module

Deprecation.method(self.class, :error_module, note: 'See :error_mapper', sunset: '0.9.0')
self.error_mapper = error_module
end
end

Expand Down Expand Up @@ -442,11 +430,7 @@ def run_exec(status, cached_value, cache_key)

# @return [Boolean] True if the circuit transitioned to closed
def success!(status)
if deprecated_entry?
storage.entry(self, Faulty.current_time, true, nil)
else
storage.entry(self, Faulty.current_time, true)
end
storage.entry(self, Faulty.current_time, true, nil)
closed = close! if status.half_open?

options.notifier.notify(:circuit_success, circuit: self)
Expand All @@ -455,11 +439,7 @@ def success!(status)

# @return [Boolean] True if the circuit transitioned to open
def failure!(status, error)
status = if deprecated_entry?
storage.entry(self, Faulty.current_time, false, status)
else
deprecated_entry(status)
end
status = storage.entry(self, Faulty.current_time, false, status)
options.notifier.notify(:circuit_failure, circuit: self, status: status, error: error)

if status.half_open?
Expand All @@ -471,23 +451,6 @@ def failure!(status, error)
end
end

def deprecated_entry?
return @deprecated_entry unless @deprecated_entry.nil?

@deprecated_entry = storage.method(:entry).arity == 4
end

def deprecated_entry(status)
Faulty::Deprecation.deprecate(
'Returning entries array from entry',
note: 'see Storate::Interface#entry',
sunset: '0.9'
)

entries = storage.entry(self, Faulty.current_time, false)
Status.from_entries(entries, **status.to_h)
end

def skipped!
options.notifier.notify(:circuit_skipped, circuit: self)
end
Expand Down
18 changes: 0 additions & 18 deletions spec/circuit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,24 +305,6 @@
end
end

context 'with error_module' do
let(:options) do
{
cache: cache,
error_module: custom_error_module,
storage: storage
}
end

around { |example| Faulty::Deprecation.silenced(&example) }

it 'raises custom errors' do
expect do
circuit.run { raise 'fail' }
end.to raise_error(custom_error_module::CircuitFailureError)
end
end

context 'with error_mapper lambda' do
let(:options) do
{
Expand Down

0 comments on commit 8dc026a

Please sign in to comment.