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

feat(handler, s3store): implement ServerDataStore for direct content serving #1208

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pcfreak30
Copy link

@pcfreak30 pcfreak30 commented Oct 20, 2024

  • Add ContentServerDataStore interface
  • Update handlers to use ContentServerDataStore when available
  • Implement range request handling for s3upload
  • Add tests for new ContentServerDataStore functionality
  • Update Go version to 1.22.1

Closes #1064

@pcfreak30
Copy link
Author

Please note I tried to avoid changing the go version, but go mod tidy seems to automatically do it.

This is a draft to get feedback.

@Acconut

@Acconut Acconut changed the title feat(handler, s3store): implement ServerDataStore for direct content serving, closes #1064 feat(handler, s3store): implement ServerDataStore for direct content serving Oct 21, 2024
Copy link
Member

@Acconut Acconut left a comment

Choose a reason for hiding this comment

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

Thank you very much for working on this! I left a few comments but the direction where this is heading is looking good.

pkg/s3store/s3store.go Outdated Show resolved Hide resolved
pkg/s3store/s3store.go Outdated Show resolved Hide resolved
pkg/s3store/s3store.go Outdated Show resolved Hide resolved
pkg/s3store/s3store.go Outdated Show resolved Hide resolved
pkg/handler/composer.go Outdated Show resolved Hide resolved
@pcfreak30 pcfreak30 force-pushed the issue/1064 branch 2 times, most recently from 6e09111 to d9e8bca Compare October 21, 2024 07:47
@pcfreak30
Copy link
Author

@Acconut changes have been made. kudos.

@@ -121,6 +122,16 @@ type DataStore interface {
GetUpload(ctx context.Context, id string) (upload Upload, err error)
}

// ServableUpload defines the method for serving content directly
type ServableUpload interface {
ServeContent(ctx context.Context, w http.ResponseWriter, r *http.Request) error
Copy link
Member

Choose a reason for hiding this comment

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

This function needs proper documentation. That's best done when we have agreed on what the handler does and does not.

Copy link
Author

Choose a reason for hiding this comment

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

lmk what/when you want docs on this.

// If the data store implements ContentServerDataStore, use the ServableUpload interface
if handler.composer.UsesContentServer {
servableUpload := handler.composer.ContentServer.AsServableUpload(upload)
err = servableUpload.ServeContent(c, w, r)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the handler should set the Content-Length, Content-Type and Content-Disposition before passing it to ServeContent. The implementation can then decide to overwrite or keep them. The idea is that we already have logic for extracting the filename and filetype from metadata and this way we can keep using them.

Copy link
Author

Choose a reason for hiding this comment

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

you decide?

pkg/s3store/s3store.go Outdated Show resolved Hide resolved
Copy link
Member

@Acconut Acconut left a comment

Choose a reason for hiding this comment

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

Thank you for the updates! This is moving in the right direction and I feel like we're getting close :)

pkg/s3store/s3store.go Show resolved Hide resolved
…ontent serving, closes tus#1064

- Add ServerDataStore interface
- Implement ContentServerDataStore in S3Store with streaming support
- Add Range header support for partial content requests
- Update StoreComposer to support ContentServer capability
- Add tests for new ContentServerDataStore functionality
- Update Go version to 1.22.1
@pcfreak30
Copy link
Author

@Acconut changes have been made.

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

Successfully merging this pull request may close these issues.

handler: support HTTP range requests in GET /:upload
2 participants