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

[fix] - Add Size Method to BufferedReadSeeker and Refactor Context Timeout Handling in HandleFile #3307

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Sep 19, 2024

Description:

This PR enhances the BufferedReadSeeker with a new Size method for determining the total size of the reader and improves the HandleFile function by centralizing context timeout management.

Changes:

  1. Introduce Size Method to BufferedReadSeeker:

    • Functionality:
      Added a Size method that efficiently retrieves the total size of the underlying reader for both seekable and non-seekable sources by utilizing the existing Seek method.
  2. Refactor Context Timeout Handling in HandleFile:

    • Change:
      Moved the creation and management of the context timeout (processingCtx) outside of each handler within the HandleFile function.
    • Benefit:
      Allows context timeouts to be propagated back to the caller, enabling better external handling and monitoring of timeout events.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav requested a review from a team September 19, 2024 17:55
@ahrav ahrav marked this pull request as ready for review September 19, 2024 18:17
@ahrav ahrav requested a review from a team as a code owner September 19, 2024 18:17
}
}

// errorReader is an io.Reader that returns an error after reading a specified number of bytes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you testing a non-EOF error? Otherwise io.LimitReader may be of use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants