lib/deimos/utils/db_poller.rb in deimos-ruby-1.19.7 vs lib/deimos/utils/db_poller.rb in deimos-ruby-1.20.0

- old
+ new

@@ -10,27 +10,33 @@ 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) + 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 - # @param config_name [Symbol] + # @param config_name [DBPollerConfig] # @return [Class<Deimos::Utils::DbPoller>] def self.class_for_config(config_name) - case config_name - when :state_based - Deimos::Utils::DbPoller::StateBased + if config_name.poller_class.present? + config_name.poller_class.constantize else - Deimos::Utils::DbPoller::TimeBased + 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 PollStatus = Struct.new(:batches_processed, :batches_errored, :messages_processed) do # @return [Integer]