class Cloudtasker::WorkerWrapper
A worker class used to schedule jobs without actually instantiating the worker class. This is useful for middlewares needing to enqueue jobs in a Rails initializer. Rails 6 complains about instantiating workers in an iniitializer because of autoloading in zeitwerk mode.
Downside of this wrapper: any cloudtasker_options specified on on the worker_class will be ignored.
Attributes
worker_name[RW]
Public Class Methods
new(worker_name:, **opts)
click to toggle source
Build a new instance of the class.
@param [String] worker_class The name of the worker class. @param [Hash] **opts The worker arguments.
Calls superclass method
Cloudtasker::Worker::new
# File lib/cloudtasker/worker_wrapper.rb, line 28 def initialize(worker_name:, **opts) @worker_name = worker_name super(opts) end
Public Instance Methods
job_class_name()
click to toggle source
Override parent. Return the underlying worker class name.
@return [String] The worker class.
# File lib/cloudtasker/worker_wrapper.rb, line 38 def job_class_name worker_name end
new_instance()
click to toggle source
Return a new instance of the worker with the same args and metadata but with a different id.
@return [Cloudtasker::WorkerWrapper] <description>
# File lib/cloudtasker/worker_wrapper.rb, line 48 def new_instance self.class.new(worker_name: worker_name, job_queue: job_queue, job_args: job_args, job_meta: job_meta) end