Skip to content

Commit

Permalink
feat: add transfer timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Tulsishah committed Nov 11, 2024
1 parent 1a33f93 commit b0fa899
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion storage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ type openWriterParams struct {
chunkSize int
// chunkRetryDeadline - see `Writer.ChunkRetryDeadline`.
// Optional.
chunkRetryDeadline time.Duration
chunkRetryDeadline time.Duration
chunkTransferTimeout time.Duration

// Object/request properties

Expand Down
13 changes: 13 additions & 0 deletions storage/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ type Writer struct {
// cancellation.
ChunkRetryDeadline time.Duration

// ChunkTransferTimeOut sets a per-chunk retry transfer timeout for multi-chunk
// resumable uploads.
//
// For uploads of larger files, the Writer will attempt to retry if the
// request to upload a particular chunk stalls for some time.
// If a single chunk has been attempting to upload for longer than this
// deadline and the request fails, it will be retried. The default value
// is 8s. Users may want to pick a longer deadline if they are using larger
// values for ChunkSize or if they expect to have a slow or unreliable
// internet connection.
ChunkTransferTimeOut time.Duration

// ForceEmptyContentType is an optional parameter that is used to disable
// auto-detection of Content-Type. By default, if a blank Content-Type
// is provided, then gax.DetermineContentType is called to sniff the type.
Expand Down Expand Up @@ -188,6 +200,7 @@ func (w *Writer) openWriter() (err error) {
ctx: w.ctx,
chunkSize: w.ChunkSize,
chunkRetryDeadline: w.ChunkRetryDeadline,
chunkTransferTimeout: w.ChunkTransferTimeOut,
bucket: w.o.bucket,
attrs: &w.ObjectAttrs,
conds: w.o.conds,
Expand Down

0 comments on commit b0fa899

Please sign in to comment.