How to know a queue is "truly" done
This is more of a philosophical question. Here's the scenario:
Process A has a task that it wants to split up into chunks and throw it into a queue so it can process it in parallel. I also want to send an "It's done" email with summary statistics when the process is truly fully processed. It takes data, splits it into a known number of chunks and dispatches workers. Once the workers have been dispatched, Process A completes.
The queue worker processes its chunk, and when the queue is empty triggers Queue::after in the AppServiceProvider. That said, if there are, say 5 queue workers, they'll each trigger the Queue::after.
So how do you know, between Process A and all the queue workers, when the queue is "truly done", i.e. the last worker has finished its work?
Fun wrinkle- if the worker finishes quickly- say instantly- the worker will constantly be in a state of "I'm done and the queue is empty". That is, until Process A dispatches the next one.
I don't expect an easy answer, I'm just curious if this is a problem anyone else has encountered. Also, assume the driver isn't "sync", cuz that's too easy.
Please or to participate in this conversation.