Class: App::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/app/dispatcher.rb

Constant Summary collapse

POLL_INTERVAL =
(App::Config.poll_interval || 3).to_i
TERMINATION_TIMEOUT =
(App::Config.termination_timeout || 60).to_i
HEARTBEAT_INTERVAL =
(App::Config.heartbeat_interval || 60 * 30).to_i
MIN_THREADS =
(App::Config.dig(:thread_pool, :min_threads) || 0).to_i
MAX_THREADS =
(App::Config.dig(:thread_pool, :max_threads) || 5).to_i
MAX_QUEUE =
(App::Config.dig(:thread_pool, :max_queue) || 100).to_i
JOB_CLEANUP_INTERVAL =
(App::Config.job_cleanup_interval || 60 * 5).to_i

Class Method Summary collapse

Class Method Details

.shutdown!Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/app/dispatcher.rb', line 38

def shutdown!
  Utility::Logger.info("Shutting down connector service with pool [#{pool.class}]...")
  running.make_false
  job_cleanup_timer.shutdown
  scheduler.shutdown
  pool.shutdown
  pool.wait_for_termination(TERMINATION_TIMEOUT)

  stop_consumer!
end

.start!Object



29
30
31
32
33
34
35
36
# File 'lib/app/dispatcher.rb', line 29

def start!
  running!
  Utility::Logger.info("Starting connector service in #{App::Config.native_mode ? 'native' : 'non-native'} mode...")
  start_job_cleanup_task!
  # start sync jobs consumer
  start_consumer!
  start_polling_jobs!
end