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 (Symbol)

Returns:



26
27
28
29
30
31
32
33
# File 'lib/deimos/utils/db_poller.rb', line 26

def self.class_for_config(config_name)
  case config_name
  when :state_based
    Deimos::Utils::DbPoller::StateBased
  else
    Deimos::Utils::DbPoller::TimeBased
  end
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.mode).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