nesquena / backburner

Simple and reliable beanstalkd job queue for ruby
http://nesquena.github.com/backburner
MIT License
428 stars 68 forks source link

Realtime Progress updates #133

Closed activestylus closed 7 years ago

activestylus commented 7 years ago

Is there a way to provide feedback of a job's progress?

I was hoping that when jobs get started I could track their progress every few seconds, then use SSE to push them to the UI level.

Any ideas?

adam12 commented 7 years ago

Probably multiple ways to do this, but in the past, I've used a Job model with a progress attribute. I then create a Job and pass the Job ID when queueing, which gets fetched inside the worker and updated as necessary.

Requires repetitive lookups on the client side to fetch the progress, but perhaps you could pair it with Postgres's pub/sub (if you're using it), to be notified when to refetch and send the SSE event.

activestylus commented 7 years ago

Not far off from my actual solution. I managed to solve this problem with websockets and a loop on the server which updates a model with the job's progress. Works a treat