chaps-io/gush

Polling scenario in job

Opened this issue · 5 comments

Hey! Is it possible to implement this:

  • Check URL every minute until result is present or by global timeout
  • Continue workflow when result is available

What is the proper way of doing such a thing with gush?

Hello!

It's not strictly possible to build an explicit workflow that loops because we use acyclic graphs underneath, but you could make a blocking job that loops inside it waiting on data to appear.

There was an idea for branching workflows but it was never fleshed out #65

@pokonski Thanks for the answer.
My initial thought was to fail job if data is not ready, so it's restarted later. Will this work?

That is right! Failed jobs do not enqueue further jobs of the workflow, so you can use it as a short circuit :) (Source: https://github.com/chaps-io/gush/blob/master/lib/gush/worker.rb#L23)

Thanks, is there any proper way of failing a job and schedule it without raising error notifications system and with the compliance with gush API?

That topic is outside of Gush, it raises an exception inside the job, you can rescue from it in ActiveJob https://api.rubyonrails.org/classes/ActiveJob/Exceptions.html