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

Add support to stop SpinGroup and show interrupt debrief #569

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

tjwp
Copy link
Contributor

@tjwp tjwp commented Nov 25, 2024

This change adds new capabilities to SpinGroup:

  • interrupt_debrief: This option, specified when initializing the SpinGroup, displays the debrief when the SpinGroup is interrupted. This is useful to interrupt and see an error without waiting for all tasks to complete.
  • SpinGroup#stop, SpinGroup#stopped?: Programmatic support for stopping a SpinGroup. Exposing this method allows a SpinGroup to be stopped when a task fails, which can be used to implement fail-fast behavior.
  • SpinGroup::Task#on_done: Support for a callback executed when a task transitions to done. This can be used to take action based on success or failure, and again can be used as part of an implementation of fail-fast behavior.

The "primitives" above are implemented instead of a specific "fail-fast" option because they provide more flexibility.

The #on_done callback is specified on the Task because it also provides more flexibility. With this approach, each task gets its own callback and additional state may be captured in the closure specified, whereas a callback on the SpinGroup would be shared across all tasks and, even if it received the task as an argument, it would only have access to the current state of the task.

@tjwp tjwp requested a review from a team as a code owner November 25, 2024 13:07
@tjwp tjwp merged commit 4d3fcf8 into main Nov 25, 2024
15 checks passed
@tjwp tjwp deleted the tjwp/spin-group-stop branch November 25, 2024 15:21
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

Successfully merging this pull request may close these issues.

2 participants