Class: Cangaroo::PollJob
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Job
#payload, #source_connection, #type
#job_tags
Instance Attribute Details
#current_time ⇒ Object
Returns the value of attribute current_time.
5
6
7
|
# File 'app/jobs/cangaroo/poll_job.rb', line 5
def current_time
@current_time
end
|
Instance Method Details
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/jobs/cangaroo/poll_job.rb', line 11
def perform(*)
@current_time = DateTime.now
if !perform?(current_time)
Cangaroo.logger.info 'skipping poll', job_tags
return
end
restart_flow(connection_request)
update_last_poll_timestamp
end
|
24
25
26
27
|
# File 'app/jobs/cangaroo/poll_job.rb', line 24
def perform?(execution_time)
last_poll_timestamp.nil? ||
execution_time.to_i - last_poll_timestamp.to_i > self.class.frequency
end
|
7
8
9
|
# File 'app/jobs/cangaroo/poll_job.rb', line 7
def transform
{ last_poll: last_poll_timestamp.to_i }
end
|