Class: Sidekiq::Portal
- Inherits:
-
Object
- Object
- Sidekiq::Portal
- Includes:
- GlobalInterface
- Defined in:
- lib/portal/version.rb,
lib/sidekiq_portal.rb,
lib/portal/errors.rb
Overview
Defined Under Namespace
Modules: CoreExtensions, GlobalInterface Classes: Config, Job, JobManager, JobRegistry, JobRunner, Lock, Timeline
Constant Summary collapse
- VERSION =
'0.3.0'- Error =
Class.new(StandardError)
- ArgumentError =
Class.new(ArgumentError)
- NonScheduledJobClassError =
Class.new(Error)
- JobConfigurationNotFoundError =
Class.new(Error)
- NonSchedulableJobError =
Class.new(Error)
- UnsupportedCoreDependencyError =
Class.new(Error)
- CoreDependencyNotFoundError =
Class.new(Error)
- ConfusingJobConfigError =
Class.new(Error)
Instance Attribute Summary collapse
- #config ⇒ Sidekiq::Portal::Config readonly
Instance Method Summary collapse
- #configure(&configuration) {|config| ... } ⇒ void
- #initialize(&configuration) {|config| ... } ⇒ void constructor
- #run_all ⇒ void
- #run_job(job_klass) ⇒ void
- #setup!(&configuration) ⇒ void (also: #reload!) private
Methods included from GlobalInterface
Constructor Details
#initialize(&configuration) {|config| ... } ⇒ void
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
#config ⇒ Sidekiq::Portal::Config (readonly)
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.
74 75 76 |
# File 'lib/sidekiq_portal.rb', line 74 def configure(&configuration) thread_safe { config.configure(&configuration) } end |
#run_all ⇒ void
This method returns an undefined value.
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.
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.
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 |