-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: include queues and worker index as arguments to on_worker_start
hook
#513
Comments
Oh, interesting! I've never used the index/key argument of Puma's |
Looking at the source code for Puma, I'm oversimplifying but it effectively does this: worker_count.times do
# find lowest index that's not in use by
# a currently running worker
index = next_worker_index
fork { spawn_worker(index) }
end So it'll try to reuse IDs whenever it has to refork. In the case of SolidQueue, I'm thinking something similar? For example, given a worker config like this: workers:
- queues: ["background"]
threads: <%= ENV.fetch("SQ_BACKGROUND_JOB_THREADS", 3) %>
processes: 1
polling_interval: 0.1
- queues: ["fast_jobs"]
threads: <%= ENV.fetch("SQ_FAST_JOB_THREADS", 3) %>
processes: 1
polling_interval: 0.1
- queues: ["slow_jobs"]
threads: <%= ENV.fetch("SQ_SLOW_JOB_THREADS", 3) %>
processes: 2
polling_interval: 0.1
|
Solid Queue currently doesn't keep that kind of index per worker and workers don't know about their position within the list 🤔 Plus, the order is not really guaranteed, if they're registered and spawned in order, it's by chance. They do have a unique name that gets generated when they're registered, though. Maybe that could be used 🤔 |
For metrics reporting this would be helpful to know, much in the same way that Puma's
on_worker_boot
hook will receive the index of the current worker.If such a feature would be accepted I may be able to work on a PR for it this weekend.
The text was updated successfully, but these errors were encountered: