Class: Core::Scheduler
- Inherits:
-
Object
show all
- Defined in:
- lib/core/scheduler.rb
Instance Method Summary
collapse
Constructor Details
#initialize(poll_interval, heartbeat_interval) ⇒ Scheduler
Returns a new instance of Scheduler.
20
21
22
23
24
|
# File 'lib/core/scheduler.rb', line 20
def initialize(poll_interval, heartbeat_interval)
@poll_interval = poll_interval
@heartbeat_interval = heartbeat_interval
@is_shutting_down = false
end
|
Instance Method Details
#connector_settings ⇒ Object
26
27
28
|
# File 'lib/core/scheduler.rb', line 26
def connector_settings
raise 'Not implemented'
end
|
#shutdown ⇒ Object
61
62
63
64
|
# File 'lib/core/scheduler.rb', line 61
def shutdown
Utility::Logger.info("Shutting down scheduler #{self.class.name}.")
@is_shutting_down = true
end
|
#when_triggered ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/core/scheduler.rb', line 30
def when_triggered
loop do
connector_settings.each do |cs|
if sync_triggered?(cs)
yield cs, :sync
end
if heartbeat_triggered?(cs)
yield cs, :heartbeat
end
if configuration_triggered?(cs)
yield cs, :configuration
end
if filtering_validation_triggered?(cs)
yield cs, :filter_validation
end
end
rescue *Utility::AUTHORIZATION_ERRORS => e
Utility::ExceptionTracking.log_exception(e, 'Could not retrieve connectors settings due to authorization error.')
rescue StandardError => e
Utility::ExceptionTracking.log_exception(e, 'Sync failed due to unexpected error.')
ensure
if @is_shutting_down
break
end
if @poll_interval > 0 && !@is_shutting_down
Utility::Logger.debug("Sleeping for #{@poll_interval} seconds in #{self.class}.")
sleep(@poll_interval)
end
end
end
|