Class: Fuey::Reporters::NotificationQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/fuey_client/fuey/reporters/notification_queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis) ⇒ NotificationQueue

Returns a new instance of NotificationQueue.



7
8
9
# File 'lib/fuey_client/fuey/reporters/notification_queue.rb', line 7

def initialize(redis)
  @_redis = redis
end

Instance Method Details

#publish_complete(args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fuey_client/fuey/reporters/notification_queue.rb', line 23

def publish_complete(args)
  trace = args.first
  message = {
    :time => Time.now.strftime("%Y%m%d%H%M%S"),
    :name => trace.name,
    :status => trace.status,
    :status_message => trace.status_message,
    :steps => trace.steps.map(&:status).map(&:attributes)
  }
  @_redis.lpush trace.name.downcase, message.to_json
end

#publish_new(args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/fuey_client/fuey/reporters/notification_queue.rb', line 35

def publish_new(args)
  trace_name, statuses = args[0], args[1]
  message = {
    :name => trace_name,
    :status => "executed",
    :status_message => "",
    :steps => statuses.map(&:attributes)
  }
  @_redis.publish "fuey.trace.new", message.to_json
end

#publish_update(args) ⇒ Object



16
17
18
19
20
21
# File 'lib/fuey_client/fuey/reporters/notification_queue.rb', line 16

def publish_update(args)
  trace_name, statuses = args[0], args[1]
  status = statuses.first
  message = [ trace_name, status.attributes ]
  @_redis.publish "fuey.trace.update", message.to_json
end

#update(type, *args) ⇒ Object



11
12
13
14
# File 'lib/fuey_client/fuey/reporters/notification_queue.rb', line 11

def update(type, *args)
  self.send("publish_#{type}", args)
  true
end