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

update ReadFrom and ReadFromWithConcurrency docs #588

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,8 @@ func (f *File) writeAt(b []byte, off int64) (written int, err error) {
// Giving a concurrency of less than one will default to the Client’s max concurrency.
//
// Otherwise, the given concurrency will be capped by the Client's max concurrency.
//
// This method is preferred over calling ReadFrom to guarantee concurrent reads/writes.
puellanivis marked this conversation as resolved.
Show resolved Hide resolved
func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64, err error) {
f.mu.Lock()
defer f.mu.Unlock()
Expand Down Expand Up @@ -1916,6 +1918,17 @@ func (f *File) readFromWithConcurrency(r io.Reader, concurrency int) (read int64
// This method is preferred over calling Write multiple times
// to maximise throughput for transferring the entire file,
// especially over high-latency links.
//
// If client uses concurrent writes, given r needs to implement one of the interfaces:
puellanivis marked this conversation as resolved.
Show resolved Hide resolved
//
// Len() int
// Size() int64
// Stat() (os.FileInfo, error)
//
// or be an instance of [io.LimitedReader] to determine the number of possible
// concurrent requests. Otherwise, reads/writes are performed in nonparallel, sliced
// in chunks with the max packet size. ReadFromWithConcurrency explicit call can
puellanivis marked this conversation as resolved.
Show resolved Hide resolved
// guarantee concurrent processing of the reader.
puellanivis marked this conversation as resolved.
Show resolved Hide resolved
func (f *File) ReadFrom(r io.Reader) (int64, error) {
f.mu.Lock()
defer f.mu.Unlock()
Expand Down