-
Notifications
You must be signed in to change notification settings - Fork 662
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
Conversation
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.
lgtm
// 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 |
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.
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?
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.
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
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
andCancel
function that are called, there is a singleExecute
which takes in the results of resolving the dependencies.How this was tested