chaps-io / gush

Fast and distributed workflow runner using ActiveJob and Redis
MIT License
1.05k stars 106 forks source link

Polling scenario in job #98

Open arrowcircle opened 1 year ago

arrowcircle commented 1 year ago

Hey! Is it possible to implement this:

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

pokonski commented 1 year ago

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 https://github.com/chaps-io/gush/issues/65

arrowcircle commented 1 year ago

@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?

pokonski commented 1 year ago

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)

arrowcircle commented 1 year ago

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?

pokonski commented 1 year ago

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