Class: Queues
- Inherits:
-
InformatorBase
- Object
- InformatorBase
- Queues
- Defined in:
- lib/ns24-dashing-collector/informators/queues.rb
Instance Attribute Summary collapse
-
#prev_q ⇒ Object
Returns the value of attribute prev_q.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize ⇒ Queues
constructor
A new instance of Queues.
- #metric ⇒ Object
Constructor Details
#initialize ⇒ Queues
Returns a new instance of Queues.
7 8 9 10 11 |
# File 'lib/ns24-dashing-collector/informators/queues.rb', line 7 def initialize # configurize host = '172.22.11.142' @redis = Redis::Namespace.new('staging-resque', redis: Redis.new(host: host)) end |
Instance Attribute Details
#prev_q ⇒ Object
Returns the value of attribute prev_q.
15 16 17 |
# File 'lib/ns24-dashing-collector/informators/queues.rb', line 15 def prev_q @prev_q end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
13 14 15 |
# File 'lib/ns24-dashing-collector/informators/queues.rb', line 13 def redis @redis end |
Instance Method Details
#info ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ns24-dashing-collector/informators/queues.rb', line 21 def info queues = redis.smembers('queues') q = queues.reduce(0) do |memo, el| memo += redis.llen("queue:#{el}") memo end res = {current: q, last: prev_q || q} self.prev_q = q res end |
#metric ⇒ Object
17 18 19 |
# File 'lib/ns24-dashing-collector/informators/queues.rb', line 17 def metric 'queue_size' end |