Class: JobTick::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/jobtick/registry.rb

Class Method Summary collapse

Class Method Details

.sync(sync: true) ⇒ Object

sync: true blocks the caller until the register POST completes (used by rake jobtick:sync, whose printed count must be truthful). The railtie boot hook passes sync: false so a slow or unreachable API cannot delay every process boot.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jobtick/registry.rb', line 9

def self.sync(sync: true)
  monitors = [
    Parsers::Whenever.parse,
    Parsers::SolidQueue.parse,
    Parsers::Sidekiq.parse
  ].flatten.compact

  JobTick.monitor_map = build_monitor_map(monitors)

  return [] if monitors.empty?

  app_name = Rails.application.class.module_parent_name if defined?(Rails)
  options  = { app_name: app_name, sync: sync }
  options[:prune] = true if JobTick.config.prune
  JobTick.client.register(monitors, **options)
  monitors
end