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

Remove Cancel from the Job interface #3127

Merged
merged 5 commits into from
Jun 18, 2024

Conversation

StephenButtolph
Copy link
Contributor

Why this should be merged

The prior implementation seemed to be a bit unintuitive with how cancellation was implemented and used by the voter job. This PR is attempting to make the behavior as explicit as possible.

How this works

Rather than having Execute and Cancel function that are called, there is a single Execute which takes in the results of resolving the dependencies.

How this was tested

  • Updated the unit tests

@StephenButtolph StephenButtolph added consensus This involves consensus cleanup Code quality improvement labels Jun 18, 2024
Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

snow/engine/snowman/job/scheduler.go Outdated Show resolved Hide resolved
snow/engine/snowman/job/scheduler.go Show resolved Hide resolved
// Job is a unit of work that can be executed based on the result of resolving
// requested dependencies.
type Job[T any] interface {
Execute(ctx context.Context, fulfilled []T, abandoned []T) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was the price for getting rid of Cancel - needing to provide more context to Execute in the form of the fulfilled/abandoned slices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. I think this makes it implicitly clear that every dependency is going to be resolved before execution. Whereas before the reliance on no short-circuiting for Cancel wasn't clear

@StephenButtolph StephenButtolph merged commit 61a5a27 into refactor-event-queue Jun 18, 2024
18 checks passed
@StephenButtolph StephenButtolph deleted the remove-job-cancel branch June 18, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement consensus This involves consensus
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants