SlmQueueDoctrine icon indicating copy to clipboard operation
SlmQueueDoctrine copied to clipboard

Expose more about job using metadata

Open roelvanduijnhoven opened this issue 5 years ago • 6 comments

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.

roelvanduijnhoven avatar May 25 '20 09:05 roelvanduijnhoven

@basz What do you think about this PR?

roelvanduijnhoven avatar May 25 '20 09:05 roelvanduijnhoven

We could -eventually- consider adding an interface exposing these additions? 🤷‍♂️

DoctrineJobInterface extends https://github.com/JouwWeb/SlmQueue/blob/master/src/Job/JobInterface.php

basz avatar May 25 '20 10:05 basz

@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 ..

roelvanduijnhoven avatar Jun 04 '20 14:06 roelvanduijnhoven

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 avatar Jun 04 '20 14:06 basz

@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 DoctrineJobInterface with utility methods that read from metadata.

I think that is an enhancement to my original proposal. And... maybe also what you meant initially?

roelvanduijnhoven avatar Jun 04 '20 14:06 roelvanduijnhoven

sounds decent! 👍

basz avatar Jun 04 '20 14:06 basz