Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polling scenario in job #98

Open
arrowcircle opened this issue Jan 17, 2023 · 5 comments
Open

Polling scenario in job #98

arrowcircle opened this issue Jan 17, 2023 · 5 comments

Comments

@arrowcircle
Copy link

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?

@pokonski
Copy link
Contributor

pokonski commented Jan 17, 2023

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

@arrowcircle
Copy link
Author

@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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

pokonski commented Jan 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants