-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Change source reporter interfaces to not return errors #3900
base: main
Are you sure you want to change the base?
Conversation
return reporter.UnitErr(ctx, err) | ||
reporter.UnitErr(ctx, err) | ||
return nil |
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.
For the cases where we were returning the reporter error, I changed it to return nil
. This would be a behavior change for context cancellations, so maybe we should return ctx.Err()
instead. Thoughts?
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.
I think that returning ctx.Err()
instead is a good idea!
81aac74
to
471744c
Compare
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.
If I understand this PR correctly, it (effectively) removes context cancellation checks from a lot of places (anywhere that used to check for a non-nil
error returned from a reporter, and return if one was found). Do we need to re-add them explicitly?
func (c ChanReporter) ChunkOk(ctx context.Context, chunk Chunk) error { | ||
return common.CancellableWrite(ctx, c.Ch, &chunk) | ||
func (c ChanReporter) ChunkOk(ctx context.Context, chunk Chunk) { | ||
_ = common.CancellableWrite(ctx, c.Ch, &chunk) |
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 leave a comment explaining what kind of errors can get swallowed here and why that's ok to do?
That's correct. Additionally, it removes confirmation of whether the item was successfully handled. That is the main tradeoff of this change. The argument is that sources shouldn't need to care whether the item was handled or not. They do need to be context aware, though. |
Yep, so then should this PR re-add the (implicit) context cancellation checks that it's removed? |
Description:
The error was meant to allow the reporter to end scanning, but in practice would only be useful for context cancellations, which sources should be handling anyway. Removing the error simplifies the usage of the interface.
Checklist:
make test-community
)?make lint
this requires golangci-lint)?