-
Notifications
You must be signed in to change notification settings - Fork 153
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
Have all processes yield self to lifecycle hooks #516
base: main
Are you sure you want to change the base?
Have all processes yield self to lifecycle hooks #516
Conversation
c2a0780
to
2a25d7f
Compare
Hey @Th3-M4jor, thanks for this! However, I still don't understand the need for an incremental index for each worker 🤔 Could you elaborate more why this is necessary? These indexes would be duplicated across different supervisors (in the case you're running jobs in multiple machines). All processes now have a unique generated name, which is used to locate them, and they carry other identifying information such as the hostname where they're running and their PID. Wouldn't this be more than enough to identify them? |
For my particular case having an incremented index for each worker fits better for metrics reporting. It more closely mirrors how Puma identifies each of its forked workers, and I already inject the k8s pod name when reporting metrics to differentiate there. Though I do see the point that it might not work for everyone's needs, what if I renamed |
I think you don't need a About |
0b5e0e7
to
b89c29c
Compare
Fair enough, I removed all references to |
Cool! I think, for simplicity, we could have all processes do this, not just workers. |
b89c29c
to
1df5a2d
Compare
Done, and similarly made a few additional things on each process class private if they were only accessed via tests or from within the class itself. |
SolidQueue.on_worker_stop do |worker| | ||
Rails.logger.info "Worker #{worker.name} stopped with queues: #{worker.queues.join(',')}" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is just because these are examples, but Solid Queue's log subscriber already logs all this when processes start and stop 🤔 I'm just not sure if it's ok to add examples that would be discouraged because you'd end up with duplicated/redundant logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to instead set a couple values in a somewhat contrived MyMetricsReporter
class, which hopefully does a better job of showing what someone might want to use it for.
1df5a2d
to
cdd9bf2
Compare
Makes it so that Workers will yield self to life cycle hooks and makes some adjustments related to what's public/private in them.
I did not do this for the dispatcher or supervisor as I felt that did not make sense.
closes #513