class Portal::JobRunner
@api private @since 0.1.0
Attributes
retry_count[R]
@return [Integer]
@api private @since 0.1.0
retry_on_exceptions[R]
@return [Arrray<Class<Exception>>]
@api private @since 0.1.0
Public Class Methods
new(retry_count, retry_on_exceptions)
click to toggle source
@param retry_count
[Integer] @parma retry_on_exceptions
[Array<Class<Exception>>] @return [void]
@api private @since 0.1.0
# File lib/portal/job_runner.rb, line 14 def initialize(retry_count, retry_on_exceptions) @retry_count = retry_count @retry_on_exceptions = retry_on_exceptions end
Public Instance Methods
run(job)
click to toggle source
@param job [Sidekiq::Portal::Job]
@api private @since 0.1.0
# File lib/portal/job_runner.rb, line 23 def run(job) return unless time_has_come?(job) actualize_internal_job_state(job) perform(job) end
Private Instance Methods
actualize_internal_job_state(job)
click to toggle source
@param job [Sidekiq::Portal::Job] @return [void]
@api private @since 0.1.0
# File lib/portal/job_runner.rb, line 57 def actualize_internal_job_state(job) job.timeline.actualize_time! end
perform(job, perform_attempt = 1)
click to toggle source
@param job [Sidekiq::Portal::Job] @param perform_attempt [Integer] @return [void]
@raise [Exception]
@api private @since 0.1.0
# File lib/portal/job_runner.rb, line 69 def perform(job, perform_attempt = 1) job.klass.perform_later rescue => error if retry_on_exceptions.include?(error.class) (perform_attempt == retry_count) ? raise(error) : perform(job, perform_attempt.next) else raise(error) end end
time_has_come?(job)
click to toggle source
@param job [Sidekiq::Portal::Job] @return [Boolean]
@api private @since 0.1.0
# File lib/portal/job_runner.rb, line 48 def time_has_come?(job) job.timeline.time_has_come? end