Class: RCelery::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/rcelery/events.rb

Class Method Summary collapse

Class Method Details

.hostnameObject



5
6
7
# File 'lib/rcelery/events.rb', line 5

def self.hostname
  Socket.gethostname
end

.task_failed(uuid, exception, traceback) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/rcelery/events.rb', line 48

def self.task_failed(uuid, exception, traceback)
  RCelery.publish(:event, {
    :type => 'task-failed',
    :uuid => uuid,
    :exception => exception,
    :traceback => traceback,
    :hostname => hostname,
    :timestamp => timestamp
  }, :routing_key => 'task.failed')
end

.task_received(uuid, name, args, kwargs, retries = 0, eta = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rcelery/events.rb', line 13

def self.task_received(uuid, name, args, kwargs, retries = 0, eta = nil)
  RCelery.publish(:event, {
    :type => 'task-received',
    :uuid => uuid,
    :name => name,
    :args => args,
    :kwargs => kwargs,
    :retries => retries,
    :eta => eta,
    :hostname => hostname,
    :timestamp => timestamp
  }, :routing_key => 'task.received')
end

.task_retried(uuid, exception, traceback) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/rcelery/events.rb', line 59

def self.task_retried(uuid, exception, traceback)
  RCelery.publish(:event, {
    :type => 'task-retried',
    :uuid => uuid,
    :exception => exception,
    :traceback => traceback,
    :hostname => hostname,
    :timestamp => timestamp
  }, :routing_key => 'task.retried')
end

.task_started(uuid, pid) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/rcelery/events.rb', line 27

def self.task_started(uuid, pid)
  RCelery.publish(:event, {
    :type => 'task-started',
    :uuid => uuid,
    :hostname => hostname,
    :timestamp => timestamp,
    :pid => pid
  }, :routing_key => 'task.started')
end

.task_succeeded(uuid, result, runtime) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/rcelery/events.rb', line 37

def self.task_succeeded(uuid, result, runtime)
  RCelery.publish(:event, {
    :type => 'task-succeeded',
    :uuid => uuid,
    :result => result,
    :hostname => hostname,
    :timestamp => timestamp,
    :runtime => runtime,
  }, :routing_key => 'task.succeeded')
end

.timestampObject



9
10
11
# File 'lib/rcelery/events.rb', line 9

def self.timestamp
  Time.now.to_f
end

.worker_heartbeat(sw_ident, sw_ver, sw_sys) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/rcelery/events.rb', line 81

def self.worker_heartbeat(sw_ident, sw_ver, sw_sys)
  RCelery.publish(:event, {
    :type => 'worker-heartbeat',
    :sw_ident => sw_ident,
    :sw_ver => sw_ver,
    :sw_sys => sw_sys,
    :hostname => hostname,
    :timestamp => timestamp
  }, :routing_key => 'worker.heartbeat')
end

.worker_offline(sw_ident, sw_ver, sw_sys) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/rcelery/events.rb', line 92

def self.worker_offline(sw_ident, sw_ver, sw_sys)
  RCelery.publish(:event, {
    :type => 'worker-offline',
    :sw_ident => sw_ident,
    :sw_ver => sw_ver,
    :sw_sys => sw_sys,
    :hostname => hostname,
    :timestamp => timestamp
  }, :routing_key => 'worker.offline')
end

.worker_online(sw_ident, sw_ver, sw_sys) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/rcelery/events.rb', line 70

def self.worker_online(sw_ident, sw_ver, sw_sys)
  RCelery.publish(:event, {
    :type => 'worker-online',
    :sw_ident => sw_ident,
    :sw_ver => sw_ver,
    :sw_sys => sw_sys,
    :hostname => hostname,
    :timestamp => timestamp
  }, :routing_key => 'worker.online')
end