From 0956316dec06f394c5529b30932a61528a38fac1 Mon Sep 17 00:00:00 2001 From: tpei Date: Thu, 2 Apr 2020 16:33:35 +0200 Subject: [PATCH] Time.new was removed in 0.33.0, needs to be Time.local now --- src/circuit_breaker.cr | 10 +++++----- src/error_watcher.cr | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/circuit_breaker.cr b/src/circuit_breaker.cr index f20777f..12a332c 100644 --- a/src/circuit_breaker.cr +++ b/src/circuit_breaker.cr @@ -22,7 +22,7 @@ class CircuitBreaker # ``` def initialize(threshold @error_threshold, timewindow timeframe, reenable_after @duration, handled_errors = [] of Exception, ignored_errors = [] of Exception) @state = CircuitState.new - @reclose_time = Time.new + @reclose_time = Time.local @error_watcher = ErrorWatcher.new(Time::Span.new(0, 0, timeframe)) # two-step initialization because of known crystal compiler bug @@ -105,13 +105,13 @@ class CircuitBreaker private def trip @state.trip - @reclose_time = Time.new + Time::Span.new(0, 0, @duration) + @reclose_time = Time.local + Time::Span.new(0, 0, @duration) end private def reset @state.reset - @reclose_time = Time.new + @reclose_time = Time.local @error_watcher.reset end @@ -120,7 +120,7 @@ class CircuitBreaker end private def reclose? - if Time.new > @reclose_time + if Time.local > @reclose_time @state.attempt_reset true else @@ -130,7 +130,7 @@ class CircuitBreaker private def open_circuit @state.trip - @reclose_time = Time.new + Time::Span.new(0, 0, @duration) + @reclose_time = Time.local + Time::Span.new(0, 0, @duration) end end diff --git a/src/error_watcher.cr b/src/error_watcher.cr index 4d850f8..0005d1d 100644 --- a/src/error_watcher.cr +++ b/src/error_watcher.cr @@ -7,11 +7,11 @@ class ErrorWatcher end def add_failure - @failures << Time.new + @failures << Time.local end def add_execution - @executions << Time.new + @executions << Time.local end def reset @@ -37,7 +37,7 @@ class ErrorWatcher end private def clean_old(arr : Array(Time)) - threshold = Time.new - @timeframe + threshold = Time.local - @timeframe arr.reject! { |time| time < threshold } end