Reputation: 295
I'm trying to queue a Sidekiq worker that does not exist in my project but exists in some other project sharing the same redis server.
In our current situation, we have two servers:
API server runs on Heroku. Web instance for the REST API and worker with Sidekiq listening to the :api
queue.
Processing server runs on AWS ElasticBeanstalk with a puma instance running a REST Full API with Sinatra. This instance runs Sidekiq and listens to the queue :processing
Side note: In the beginning, our API was doing all the work but as some workers started taking too much memory, we switch to the processing server.
When we need to execute a job on the processing server we have these actions happening:
API calls POST processing.com/some_job
Processing queues SomeJobWorker
on queue processing
Processing executes SomeJobWorker
from queue processing
Processing calls POST api.com/webhooks/some_job_result
API queues SomeJobResultWorker
on queue api
API executes SomeJobResultWorker
from queue processing
This got me thinking if I could somehow, from the API server directly queue SomeJobWorker
then I could get rid of the REST API on our processing server.
... then I could get rid of the webhooks
endpoint on the API server and do the same from the processing server
I would end up with something like this:
API calls queues SomeJobWorker
Processing executes SomeJobWorker
Processing queues SomeJobResultWorker
API executes SomeJobResultWorker
Is there a way for me to queue a worker that does not exist on my local code base?
Upvotes: 0
Views: 296
Reputation: 22238
You have two shards. Each Redis is a shard. Read this page:
https://github.com/mperham/sidekiq/wiki/Sharding
You can push a job using the class name:
client = Sidekiq::Client.new(PROCESSING_REDIS)
client.push('queue' => 'api', 'class' => 'FooWorker', 'args' => [1,2,"foo"])
Upvotes: 1