SlmQueueDoctrine
SlmQueueDoctrine copied to clipboard
Expose more about job using metadata
This PR extends the DoctrineQueue to publish scheduled and priority. Previously only id got exposed to the outside world.
My use-case is that I would like to add a strategy that can send the time it took before the job started to an outside monitoring system.
@basz What do you think about this PR?
We could -eventually- consider adding an interface exposing these additions? 🤷♂️
DoctrineJobInterface extends https://github.com/JouwWeb/SlmQueue/blob/master/src/Job/JobInterface.php
@basz Mm. When I read your post that made sense. But.. now I am implementing it, it does not seem to work.
The JobManager returns job instances: so it is up to the user of this application to decide what is returned, and what interface that thing will adhere to. I do not think it is a good idea to force them to implement the DoctrineJobInterface.
I think the path I initially took is still our best bet. Although that does feel somewhat hacky ..
Ok.
But,... We don't need to force users to use it. They may use an DoctrineJobInterface on their Jobs. The JobManager doesn't care... Still returns JobInterfaces. I agree it would mainly be for IDE code completion...
@basz The way I am intending to use this feature is to track how long it took before a job gets executed, after it's scheduled date has passed. That will however only give a proper reading if all jobs implement this. And this fails to work if you import a job that depends on SlmQueue from another repo.
But I do get your point... What if we do both?
- We always write the metadata.
- We provide a
DoctrineJobInterfacewith utility methods that read from metadata.
I think that is an enhancement to my original proposal. And... maybe also what you meant initially?
sounds decent! 👍