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

Conditionally execution #42

Open
KirillSuhodolov opened this issue Oct 9, 2017 · 3 comments
Open

Conditionally execution #42

KirillSuhodolov opened this issue Oct 9, 2017 · 3 comments

Comments

@KirillSuhodolov
Copy link

In continuation of the conversation at issue #41

May be it possible to run Job only that satisfied condition. Due to in runtime, it may be not need to execute. The api can looks like:

class SupplierWorkflow < Gush::Workflow
  def configure
    run AskSupplierAboutAvailableAmount
    run TryToOrderProducts, should(or condition): ->(previous_result, passed_params) { true }
  end
end

All this questions about to adopt this gem for complex workflows, that I have in project, where they are not linear, and branching based on conditions or failures.

P.S.
When do jobs create? When method .start! on workflow ran all described jobs creates or after previous jobs executed, next creates and put to the queue?

@pokonski
Copy link
Contributor

pokonski commented Oct 10, 2017

Can you share a real life example on when one would need dynamic branching? Because this goes against the basic design of Gush.

Jobs are created when workflow is first created and persisted. But they are put on queue when any job's descendants finish successfully.

@scarfacedeb
Copy link

@pokonski I have a similar situation:

I have a pdf manual pipeline that looks like this:

database row with url -> DownloadJob -(manual.id)-> ProcessingJob -(manual.id)-> PublishJob

Gush seems like a good fit for my case, but unfortunately I also need to deal with errors on every step.

e.g. if DownloadJob failed to download the manual, I'll need to break out the workflow and update the source with the given error.

The best way to deal with it would've been a conditional execution, like:

success: DownloadJob -(:ok, manual.id)-> ProcessingJob
error: DownloadJob -(:error, ["Wrong mime type"] -> ErrorInSourceJob

@pokonski
Copy link
Contributor

Okay thanks for feedback! I'll look into that but at the same time I do not want break compatibility with older versions, so this would be most likely opt in

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

3 participants