Class: JobTick::Registry

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

Class Method Summary collapse

Class Method Details

.syncObject



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

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

  map = {}
  monitors.each { |m| map[m[:task]] = m[:key] if m[:task] }
  JobTick.monitor_map = map.freeze

  return [] if monitors.empty?

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