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
Add Job status update plugin (php-resque way) #335
Conversation
perhaps this should be named as worker.addSubscriber(new WorkerJobStatusSubscriber) where Subscriber provides method called WorkerJobStatusSubscriber.getSubscribedEvents() {
return [
'eventName' : callable,
'start': this.onStart,
]
} as this particular subscriber needs access to worker, it could be passed in constructor: worker.addSubscriber(new WorkerJobStatusSubscriber(worker)) but more flexible solution would be if it captures it on 'start' event: onStart(worker) => {
this.worker = worker;
} I come from PHP background, so this is designed by symfony/event-dispatcher: @evantahler WDYT? |
great start! Do you need help writing a test for this (and getting the linter to pass)? Also, please add an example for folks to see, and update the readme. |
@evantahler not sure what you mean by "this"?
as for example, the pull request commit contains an example on its own: you mean you want example in pull request body? ps: I'm using this "plugin" successfully with jobs submitted from php-resque |
@evantahler started the |
I think that I'm having trouble understanding the eventual usage / API you have in mind for this (and #337). Could you please start with an example that shows how you might use this? I think what I'm stuck on is that to me is seems that the person requesting the job's status is likely not on the same server as the worker... so they won't be able to subscribe to events on the worker doing the job. I'm sure this is going to be awesome, but I'm just missing something... Thank you! |
did you see updated PR body? this integration is inserted to worker. client is php-resque. #337 is to write plugins like that, and attach bulk of listeners with single line. the listeners are defined in the class. class knows what it wants to listen, and provides handlers for those. please see how Symfony event listeners are done, should help to understand the principle: |
Thank you for the example, I found that very helpful! Reading https://github.com/quirkey/resque-status, it seems that what you are trying to accomplish is to store data about jobs that lives past their completion. If that's the case, I'm still curious why the normal plugin lifecycle hooks It also looks like Also, I imagine you will need a TTL on your new data objects (it looks like https://github.com/quirkey/resque-status has a default of 24h) If you'd like to chat more realtime, please join us on the Actionhero Slack and we can make a dedicated room for this topic https://slack.actionherojs.com |
I'm not using quirkey/resque-status but resque/php-resque, and as the status handling is non-standard, they both do their own way. |
looks like adding multiWorker support for this plugin is very complicated. mostly because there's no API to contain the connection object. so for single worker plugin was just operating on worker.connection property which multiworker does not have. also, design-wise, seems multi worker creates workers with passing connection details to the worker, so each worker creates their own connection to database, while it could be optimized of connection object is passed, without need to create more connections to database for each worker. |
Yeah, I imagine so. Again, please join us on slack.actionherojs.com if you want to talk more about your use case. Your implementation is rather far-removed from the plugin interfaces we have... Regarding sharing a redis connection, you can do that today! It works for multiWorker, workers, schedulers... all the process types. Just pass in a redis client rather than connection options: node-resque/examples/multiWorker.ts Lines 8 to 22 in 6d1f9d4
|
yea, doing so, for now I'll leave it as is, I can survive 10 Redis connections per node. |
ac12679
to
3d97f89
Compare
3d97f89
to
3fe92a5
Compare
pushed changes to support multiworker. I noticed the function signatures do not match, i.e job is typed differently on methods this plugin listens to. |
9190d2e
to
b34f5d3
Compare
This adds
:status
key updating logic in redis, so that status monitoring can be used with php-resque.Refs: