mercredi 15 août 2018

How can I associate a queued job with a particular user in Laravel?

I've built a system based on Laravel where users are able to begin a "task" which repeats a number of times, with a delay between each repetition. I've accomplished this by queueing a job with an amount argument, which then recursively queues an additional job until the count is up.

For example, I start my task with 3 repetitions:

  1. A job is queued with an amount argument of 3. It is ran, the amount is decremented to 2. The same job is queued again with a delay of 5 seconds specified.
  2. When the job runs again, the process repeats with an amount of 1.
  3. The last job executes, and now that the amount has reached 0, it is not queued again and the tasks have been completed.

This is working as expected, but I need to know whether a user currently has any tasks being processed. I need to be able to do the following:

  1. Check if a particular queue has any jobs started by a particular user.
  2. Check the value that was set for amount on that job.

I'm using the database driver for a queue named tasks. Is there any existing method to accomplish my goals here?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire