Class: Sidekiq::Portal

Inherits:
Object
  • Object
show all
Includes:
GlobalInterface
Defined in:
lib/portal/version.rb,
lib/sidekiq_portal.rb,
lib/portal/errors.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Modules: CoreExtensions, GlobalInterface Classes: Config, Job, JobManager, JobRegistry, JobRunner, Lock, Timeline

Constant Summary collapse

VERSION =

Returns:

  • (String)

Since:

  • 0.1.0

Version:

  • 0.3.0

'0.3.0'
Error =

Since:

  • 0.1.0

Class.new(StandardError)
ArgumentError =

Since:

  • 0.1.0

Class.new(ArgumentError)
NonScheduledJobClassError =

Since:

  • 0.1.0

Class.new(Error)
JobConfigurationNotFoundError =

Since:

  • 0.1.0

Class.new(Error)
NonSchedulableJobError =

Since:

  • 0.1.0

Class.new(Error)
UnsupportedCoreDependencyError =

Since:

  • 0.1.0

Class.new(Error)
CoreDependencyNotFoundError =

Since:

  • 0.1.0

Class.new(Error)
ConfusingJobConfigError =

Since:

  • 0.1.0

Class.new(Error)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GlobalInterface

included

Constructor Details

#initialize(&configuration) {|config| ... } ⇒ void

Parameters:

  • configuration (Block)

Yields:

Yield Parameters:

  • config (Qonfig::Settings)

Yield Returns:

  • (void)

Since:

  • 0.1.0



45
46
47
48
# File 'lib/sidekiq_portal.rb', line 45

def initialize(&configuration)
  @lock = Sidekiq::Portal::Lock.new
  thread_safe { setup!(&configuration) }
end

Instance Attribute Details

#configSidekiq::Portal::Config (readonly)

Returns:

Since:

  • 0.1.0



35
36
37
# File 'lib/sidekiq_portal.rb', line 35

def config
  @config
end

Instance Method Details

#configure(&configuration) {|config| ... } ⇒ void

This method returns an undefined value.

Parameters:

  • configuration (Block)

Yields:

Yield Parameters:

  • config (Qonfig::DataSet)

Yield Returns:

  • (void)

Since:

  • 0.1.0



74
75
76
# File 'lib/sidekiq_portal.rb', line 74

def configure(&configuration)
  thread_safe { config.configure(&configuration) }
end

#run_allvoid

This method returns an undefined value.

Since:

  • 0.1.0



99
100
101
102
103
104
105
106
107
# File 'lib/sidekiq_portal.rb', line 99

def run_all
  thread_safe do
    job_manager.each_time_point do |time_point|
      ::Timecop.freeze(time_point) do
        job_manager.each_job { |job| job_runner.run(job) }
      end
    end
  end
end

#run_job(job_klass) ⇒ void

This method returns an undefined value.

Parameters:

  • job_klass (Class)

Since:

  • 0.1.0



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/sidekiq_portal.rb', line 83

def run_job(job_klass)
  thread_safe do
    raise(
      Sidekiq::Portal::NonSchedulableJobError,
      "#{job_klas} is not schedulable"
    ) unless job_manager.runnable?(job_klass)

    portal_job = job_manager.resolve(job_klass)
    job_runner.run(portal_job)
  end
end

#setup!(&configuration) ⇒ void Also known as: reload!

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:

  • configuration (Block)

Since:

  • 0.1.0



55
56
57
58
59
60
61
62
63
# File 'lib/sidekiq_portal.rb', line 55

def setup!(&configuration)
  thread_safe do
    Sidekiq::Portal::CoreExtensions.load!

    @config = Sidekiq::Portal::Config.new(&configuration)
    @job_manager = Sidekiq::Portal::JobManager::Builder.build(@config)
    @job_runner = Sidekiq::Portal::JobRunner::Builder.build(@config)
  end
end