Class: Connectors::Crawler::Scheduler

Inherits:
Core::Scheduler show all
Defined in:
lib/connectors/crawler/scheduler.rb

Instance Method Summary collapse

Methods inherited from Core::Scheduler

#initialize, #shutdown

Constructor Details

This class inherits a constructor from Core::Scheduler

Instance Method Details

#connector_settingsObject



18
19
20
21
22
23
# File 'lib/connectors/crawler/scheduler.rb', line 18

def connector_settings
  Core::ConnectorSettings.fetch_crawler_connectors || []
rescue StandardError => e
  Utility::ExceptionTracking.log_exception(e, 'Could not retrieve Crawler connectors due to unexpected error.')
  []
end

#when_triggeredObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/connectors/crawler/scheduler.rb', line 25

def when_triggered
  loop do
    connector_settings.each do |cs|
      # crawler only supports :sync
      if sync_triggered?(cs)
        yield cs, :sync, nil
        next
      end

      schedule_key = custom_schedule_triggered(cs)
      yield cs, :sync, schedule_key if schedule_key
    end
  rescue *Utility::AUTHORIZATION_ERRORS => e
    log_authorization_error(e)
  rescue StandardError => e
    log_standard_error(e)
  ensure
    if @is_shutting_down
      break
    end
    sleep_for_poll_interval
  end
end