Diggsey/sqlxmq

Check on job status (by uuid)

Closed this issue · 4 comments

Hi.

Is there any way I could check on a job's status by UUID? I would like to wait until it is finished or at least poll whether it is already done. Is this possible somehow or easy to integrate?

Thank you in advance!

It's not built in atm, but there are a couple of ways you could do this:

  1. Have your job insert a record when it's done. Then you can just check for the existence of that record.

  2. Query the mq_msgs table to see if the row still exists - if it does, the job is not done. This has the downside that you'll be relying on implementation details of this crate though.

Thanks, did you think of it like that? (Option 2)

This has the downside that you'll be relying on implementation details of this crate though.

Would be good to have in the library then :)

The way I sort of do this in requeuest is to have a hashmap with job uuid's as keys, and the sender half of a oneshot channel as value. The job takes the sender half from the map, and the receiver gets returned by the function spawning the job. See here and here

Thanks, yes, I have seen that. I had it before, but it has issues:

  • Needs to be manually created and managed. Every job has to do this at job completion.
  • Can cause flaws if it is not executed at the same time as job completion.
  • Doesn't work if the job is executed after application-restart.

It is more like a manual workaround and I currently don't need it in production code, just testing.