Module: Deimos::Utils::DbPoller

Defined in:
lib/deimos/utils/db_poller.rb,
lib/deimos/utils/db_poller/base.rb,
lib/deimos/utils/db_poller/time_based.rb,
lib/deimos/utils/db_poller/state_based.rb

Overview

Class which continually polls the database and sends Kafka messages.

Defined Under Namespace

Classes: Base, PollStatus, StateBased, TimeBased

Class Method Summary collapse

Class Method Details

.class_for_config(config_name) ⇒ Class<Deimos::Utils::DbPoller>

Parameters:

  • config_name (DBPollerConfig)

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/deimos/utils/db_poller.rb', line 26

def self.class_for_config(config_name)
  if config_name.poller_class.present?
    config_name.poller_class.constantize
  else
    case config_name.mode
    when :state_based
      Deimos::Utils::DbPoller::StateBased
    else
      Deimos::Utils::DbPoller::TimeBased
    end
  end
rescue NameError
    raise "Class #{config_name.poller_class} not found!"
end

.start!void

This method returns an undefined value.

Begin the DB Poller process.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/deimos/utils/db_poller.rb', line 9

def self.start!
  if Deimos.config.db_poller_objects.empty?
    raise('No pollers configured!')
  end

  pollers = Deimos.config.db_poller_objects.map do |poller_config|
    self.class_for_config(poller_config).new(poller_config)
  end
  executor = Sigurd::Executor.new(pollers,
                                  sleep_seconds: 5,
                                  logger: Deimos.config.logger)
  signal_handler = Sigurd::SignalHandler.new(executor)
  signal_handler.run!
end