Class: Queues

Inherits:
InformatorBase show all
Defined in:
lib/ns24-dashing-collector/informators/queues.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQueues

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_qObject

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

#redisObject (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

#infoObject



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

#metricObject



17
18
19
# File 'lib/ns24-dashing-collector/informators/queues.rb', line 17

def metric
  'queue_size'
end