-
Notifications
You must be signed in to change notification settings - Fork 89
Drop all post-terminal commands & sort activation jobs #502
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
Drop all post-terminal commands & sort activation jobs #502
Conversation
/// Sorts jobs in an activation to be in the order lang expects: | ||
/// `patches -> signals -> other -> queries` | ||
fn sort_act_jobs(wfa: &mut WorkflowActivation) { | ||
wfa.jobs.sort_by(|j1, j2| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm this is a "stable" sort (meaning equal things aren't reordered)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's stable.
core/src/worker/workflow/mod.rs
Outdated
(workflow_activation_job::Variant::NotifyHasPatch(_), _) => Ordering::Less, | ||
(workflow_activation_job::Variant::SignalWorkflow(_), _) => Ordering::Less, | ||
(workflow_activation_job::Variant::QueryWorkflow(_), _) => Ordering::Greater, | ||
_ => Ordering::Equal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm just for my reading that this case should never be hit because of the discriminant(j1v) == discriminant(j2v)
check above? (fine to remain for exhaustion, I just want to confirm that the match clause never compares equal elements)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it never does.
core/src/worker/workflow/mod.rs
Outdated
} | ||
match (j1v, j2v) { | ||
(workflow_activation_job::Variant::NotifyHasPatch(_), _) => Ordering::Less, | ||
(workflow_activation_job::Variant::SignalWorkflow(_), _) => Ordering::Less, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if j1v
is SignalWorkflow
and j2v
is NotifyHasPatch
? I think you should give integer ordinals to each job and then cmp
them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a reasonable way to do it. Changed.
4f167bd
to
260a568
Compare
* Drop all post-terminal commands * Sort outgoing jobs in order lang expects
* Drop all post-terminal commands * Sort outgoing jobs in order lang expects
What was changed
Drop & warn about commands following a terminal workflow command.
Also ensure jobs are sorted in the order langs are expecting anyways before sending them out.
Why?
We'll end up blowing up server-side right now, which is a bit annoying for a user to fix when we can do this instead - and not require lang layer to do it.
De-dupe lang job-sorting work and move it into core.
Checklist
Closes [Feature Request] Discard post-terminal non-query commands #497 and closes [Feature Request] Sort activation jobs by desired execution order #498
How was this tested:
Added UTs. Existing tests.
Any docs updates needed?