Class: Sidekiq::Portal::JobManager::Builder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/portal/job_manager/builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Since:

  • 0.1.0



22
23
24
25
# File 'lib/portal/job_manager/builder.rb', line 22

def initialize(config)
  @scheduled_jobs_config = config.settings.scheduler_config
  @timezone = config.settings.default_timezone
end

Class Method Details

.build(config) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

Since:

  • 0.1.0



12
13
14
# File 'lib/portal/job_manager/builder.rb', line 12

def build(config)
  new(config).build
end

Instance Method Details

#buildSidekiq::Portal::Manager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Sidekiq::Portal::Manager)

Since:

  • 0.1.0



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/portal/job_manager/builder.rb', line 31

def build
  current_time = ActiveSupport::TimeZone[timezone].at(Time.current)
  job_registry = Sidekiq::Portal::JobRegistry.new

  scheduled_jobs_config.each_pair do |job_config_series, scheduler_options|
    job_klass = resolve_job_klass(job_config_series, scheduler_options)
    cron_pattern, every_pattern = resolve_time_configuration(job_klass, scheduler_options)
    job_wrapper = build_job_wrapper(job_klass, cron_pattern, every_pattern, current_time)

    job_registry.register(job_wrapper)
  end

  Sidekiq::Portal::JobManager.new(job_registry)
end