I have this code inside a rails engine:
Superworker.create(:AJob, :a_id, :data) do
AWorker :a_id, :data do
parallel do
BWorker :a_id, :data
CWorker :a_id, :data
DWorker :a_id, :data
end
EWorker :a_id, :data
end
end
The problem I'm facing is that the workers are under the engine namespace and Superworker factory does not understand MyEngine::AWorker notation, how can this be solved? Workers path was added to the autoload path using:
module MyEngine
class Engine < ::Rails::Engine
isolate_namespace MyEngine
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '..', '..')
config.autoload_paths << File.expand_path(File.join(ENGINE_RAILS_ROOT, 'app', 'workers', 'my_engine'))
require File.expand_path(File.join(ENGINE_RAILS_ROOT, 'app', 'jobs', 'superworkers'))
end
end
What might be the problem?
UPDATE1: When trying to add namespaces to workers like this:
Superworker.create(:AJob, :a_id, :data) do
MyEngine::AWorker :a_id, :data do
parallel do
MyEngine::BWorker :a_id, :data
MyEngine::CWorker :a_id, :data
MyEngine::DWorker :a_id, :data
end
MyEngine::EWorker :a_id, :data
end
end
I get the following:
<top (required)>': undefined method `AWorker' for MyEngine:Module (NoMethodError)
from /home/vagrant/.rvm/gems/ruby-1.9.3-p392/gems/sidekiq-superworker-0.1.8/lib/sidekiq/superworker/dsl_parser.rb:15:in `instance_eval'
from /home/vagrant/.rvm/gems/ruby-1.9.3-p392/gems/sidekiq-superworker-0.1.8/lib/sidekiq/superworker/dsl_parser.rb:15:in `block in block_to_nested_hash'
I got it fixed with https://github.com/socialpandas/sidekiq-superworker/issues/23 details. It was due to a sidekiq-superworker convetion on namespaces which needs to be set using MyModule__MyWorker syntax