-
Notifications
You must be signed in to change notification settings - Fork 106
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
Shortcircuit workflows #65
Comments
Hey @linkyndy! Currently it's not possible but there was a suggestion about branching workflows in run time depending on their result, but I haven't had much time tinker with a solution for it. Right now you could spawn a new Workflow inside A if conditions are met, but it's not a nice solution IMO |
Thanks for your fast answer! Curious to see how this will develop. |
EDIT: I just re-read OP's shortcircuit scneario, my original comment is irrelevant and doesn't help at all 😄 |
Hi @linkyndy I've just reimplemented something along those lines, this is how I went about it:
However this marks the @pokonski is this how |
I don't think this can be used, because |
Yep! That's what I was aiming to achieve 😄the subsequent actions would be skipped, I think based on @linkyndy said:
I figured, that's what he/she is also aiming for.
What would this look like? Could I take a stab at this, just pseudo-code and how the usage would look like? I'll think up of something later today, some sort of proposal for this. |
One of the good examples had an idea to allow providing two paths, like so: run SomeJob,
before_success: MainJob,
before_failure: AlternativeJob, Though the naming is rather unfortunate because it suggest the MainJob will ran before SomeJob is succeesful, so needs better naming 💃 |
@ace-subido Marking the whole workflow as failed may be too harsh; @pokonski Indeed, it's not really clear from the DSL 😊 |
But coming back to the problem from the original issue by @linkyndy, one way would be to introduce a |
@pokonski so something like this:
We could also do something like
@pokonski What do you think? |
Yeah this sounds good! One clarification here:
I assume you mean skip all the jobs that were supposed to run after the job |
Yeah, probably cascade throughout |
I don't really see any value in this My initial question was related to cancelling the entire workflow from that moment on, and dealing somehow with the remaining jobs. |
If that's the case, I'll add more to the PR. Something like: |
This particular feature looks very useful for an application we are developing. I would rather be very explicit and name the methods as |
I have been using this pattern in my own workflows for a bit now and I was thinking it would be good to go over this discussion again and clear up the goals. For me, having a state change that occurs when you want to stop executing a job and move on in the workflow is useful on its own, ie the 'skip' call on a job marks that job 'skipped'. I use it as an indicator that the job halted without completing intentionally due to some conditional checks on the state of a set of records, ie 'Invoices'. So, any record (ie Invoice) whose processing job is 'skipped' can then know when it is reprocessed anywhere other than the normal workflow path that the job did or did not finish intentionally. This lets me avoid needing to track such a state within an Invoice record, isolating it to the job. This seems to lead to good data management and semantics in my opinion. The job state is tracked enough that there is no need to track additional state in a record processed within that job. I think this is meaningfully distinct from 'return' in a job as returning early does not maintain any state information that could be used for another process to look at. I think for this use case a 'skip_remaining' method would not accomplish my needs but I do think there is still room to do both. If that is too long for anyone: Look forward to having some fresh takes on these ideas! |
Let's say we have the following, simple, workflow:
And Job A checks for a value, which if
false
, the whole workflow should be stopped immediately. Is this possible at the moment with Gush?As an example, let's say we process a new user signup with the above workflow. Job A retrieves the newest user from the database. If the user has been already processed, we'd like to call the workflow complete; the subsequent steps are not necessary anymore, since the user has been already processed.
The text was updated successfully, but these errors were encountered: