lib/breakers/service.rb in breakers-0.5.0 vs lib/breakers/service.rb in breakers-0.6.0

- old
+ new

@@ -141,27 +141,27 @@ { count: value.to_i, time: times[idx] } end end def increment_key(key:) - Breakers.client.redis_connection.multi do - Breakers.client.redis_connection.incr(key) - Breakers.client.redis_connection.expire(key, @configuration[:data_retention_seconds]) + Breakers.client.redis_connection.multi do |pipeline| + pipeline.incr(key) + pipeline.expire(key, @configuration[:data_retention_seconds]) end end # Take the current or given time and round it down to the nearest minute def align_time_on_minute(time: nil) time = (time || Time.now.utc).to_i time - (time % 60) end def maybe_create_outage - data = Breakers.client.redis_connection.multi do - Breakers.client.redis_connection.get(errors_key(time: Time.now.utc)) - Breakers.client.redis_connection.get(errors_key(time: Time.now.utc - 60)) - Breakers.client.redis_connection.get(successes_key(time: Time.now.utc)) - Breakers.client.redis_connection.get(successes_key(time: Time.now.utc - 60)) + data = Breakers.client.redis_connection.multi do |pipeline| + pipeline.get(errors_key(time: Time.now.utc)) + pipeline.get(errors_key(time: Time.now.utc - 60)) + pipeline.get(successes_key(time: Time.now.utc)) + pipeline.get(successes_key(time: Time.now.utc - 60)) end failure_count = data[0].to_i + data[1].to_i success_count = data[2].to_i + data[3].to_i if failure_count > 0 && success_count == 0