[GODRIVER-3079] Implement io.ReadSeeker for the DownloadStream Created: 26/Dec/23  Updated: 08/Jan/24

Status: Backlog
Project: Go Driver
Component/s: GridFS, Networking, Performance
Affects Version/s: None
Fix Version/s: 2.1.0

Type: Improvement Priority: Unknown
Reporter: Kristopher Rahim Afful-Brown Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Context

As the client, I should have the flexibility of choosing to stream a file in it's entirety or in parts, such as using a Range Request

Here is the current definition of the DownloadStream

func (ds *DownloadStream) Skip(skip int64) (int64, error)

Whereas the http.ServeContent function requires a an `io.ReadSeeker`. From the docs, it seem this is the recommended function to use over `io.Copy` as it:

handles Range requests properly, sets the MIME type, and handles If-Match, If-Unmodified-Since, If-None-Match, If-Modified-Since, and If-Range requests.

By extending the type to implement the `ReadSeeker` interface, this creates greater consistency with the stdlib

Definition of done

Include a method for seeking. This seems to exists in s3 compatible drivers already and  this older unofficial MongoDB driver seemed to also implement this. The official driver also already seems to tackle the SeekStart/SeekCurrent with how Skip is implemented.

Pitfalls

What should the implementer watch out for? What are the risks?



 Comments   
Comment by PM Bot [ 26/Dec/23 ]

Hi kristopherab@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Thu Feb 08 08:40:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.