From 073c77d2c96cf255356fe4fa3b0099d1b0c3dc9f Mon Sep 17 00:00:00 2001 From: Stanislav Gordanov Date: Mon, 13 Mar 2017 12:37:52 +0500 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=20=D0=BF=D0=BE=D1=80=D0=BE=D0=B3=D0=BE=D0=B2=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20?= =?UTF-8?q?=D0=B8=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D1=8E=20?= =?UTF-8?q?=D0=BE=D0=B1=20=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4=D1=8F=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://jira.railsc.ru/browse/SG-5765 https://jira.railsc.ru/browse/SERVER-3277 --- lib/resque/integration/queues_info/config.rb | 9 ++++-- spec/resque/integration/queues_info_spec.rb | 31 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/resque/integration/queues_info/config.rb b/lib/resque/integration/queues_info/config.rb index 7770c2b..15d409f 100644 --- a/lib/resque/integration/queues_info/config.rb +++ b/lib/resque/integration/queues_info/config.rb @@ -27,9 +27,14 @@ def channel(queue) end def data - @data ||= @queues.map do |k, v| + @data ||= @queues.map do |queue_name, _queue_params| { - "{#QUEUE}" => k + '{#QUEUE}' => queue_name, + '{#THRESHOLD_AGE}' => max_age(queue_name), + '{#THRESHOLD_SIZE}' => max_size(queue_name), + '{#THRESHOLD_FAILURES_PER_5M}' => max_failures_count(queue_name, '5m'), + '{#THRESHOLD_FAILURES_PER_1H}' => max_failures_count(queue_name, '1h'), + '{#CHANNEL}' => channel(queue_name) } end end diff --git a/spec/resque/integration/queues_info_spec.rb b/spec/resque/integration/queues_info_spec.rb index 502b691..be30e5d 100644 --- a/spec/resque/integration/queues_info_spec.rb +++ b/spec/resque/integration/queues_info_spec.rb @@ -326,4 +326,35 @@ expect(queue_info.threshold_failures_count(third_queue_name, '1h')).to eq 70 end end + + describe '#data' do + it do + expect(queue_info.data).to eq [ + { + '{#QUEUE}' => 'first', + '{#THRESHOLD_AGE}' => 20, + '{#THRESHOLD_SIZE}' => 100, + '{#THRESHOLD_FAILURES_PER_5M}' => 15, + '{#THRESHOLD_FAILURES_PER_1H}' => 90, + '{#CHANNEL}' => 'first' + }, + { + '{#QUEUE}' => 'third', + '{#THRESHOLD_AGE}' => 30, + '{#THRESHOLD_SIZE}' => 100, + '{#THRESHOLD_FAILURES_PER_5M}' => 15, + '{#THRESHOLD_FAILURES_PER_1H}' => 70, + '{#CHANNEL}' => 'first' + }, + { + '{#QUEUE}' => 'second_queue', + '{#THRESHOLD_AGE}' => nil, + '{#THRESHOLD_SIZE}' => nil, + '{#THRESHOLD_FAILURES_PER_5M}' => nil, + '{#THRESHOLD_FAILURES_PER_1H}' => nil, + '{#CHANNEL}' => 'first second' + } + ] + end + end end