Skip to content

Releases

v1.5.2 Fix ReadAt to fully read on growing streams before returning

Choose a tag to compare

@djherbis djherbis released this 18 Nov 16:47
b046547

What's Changed

  • Fill ReadAt requests on growing streams by @omrzk in #15

New Contributors

  • @omrzk made their first contribution in #15

Full Changelog: v1.5.1...v1.5.2

Fix race between Cancel and NextReader.

Choose a tag to compare

@djherbis djherbis released this 29 Aug 20:37
e13b1e2

This resolves a race where NextReader could return a reader if it races with Cancel.
This would be "resolved" during the first Read on that Reader, but this should cause NextReader to return the cancel error instead.

Add CancelWithErr

Choose a tag to compare

@djherbis djherbis released this 29 Aug 20:31
2036d2c
Merge pull request #13 from djherbis/copilot/add-close-with-error-method

Add Stream.CancelWithErr to attach a specific cause to cancellation

Go module support

Choose a tag to compare

@djherbis djherbis released this 25 Apr 15:11
8c9a40e
v1.4.0

add go.mod

Return data as soon as possible

Choose a tag to compare

@djherbis djherbis released this 13 Apr 04:20
c873af4

#10 stops blocking to fill a buffer when we hit io.EOF but have some data to return.

Thanks to @jonasi for contributing this.

stream.Reader supports io.Seeker

Choose a tag to compare

@djherbis djherbis released this 22 Feb 21:54
668a316

See the godoc for details.
Step towards making #6 useful. I'll figure out how to add known-length streams and then Seek to io.SeekEnd quickly in those cases.

Sizable Stream Readers (Range Requests)

Choose a tag to compare

@djherbis djherbis released this 03 Mar 06:30

Stream Reader supports a new method called Size(). Size returns the size of the entire stream at this moment, and a bool which is true if and only if the stream is closed. If the stream is closed, then the size will be constant from then on, and range requests can be done via an io.SectionReader over the reader like so:

var r stream.Reader
if size, isClosed := r.Size(); isClosed {
    sr := io.NewSectionReader(r, 0, size)
    http.ServeContent(rw, req, name, modTime, sr)
}
// otherwise just do regular request writing

Concurrent Read/Write calls

Choose a tag to compare

@djherbis djherbis released this 24 Jul 21:18

tl;dr; Stream's Read/Write calls no longer block each-other, and can safely make progress concurrently.

The last version introduced locks during read/write calls to streams, which synchronized concurrent read/writes, allowing concurrent calls, but not concurrent progress to be made. This was done to insure that sync.Cond was properly broadcasting all reads/writes, so no reader missed a write.

However, this also meant that we were not taking advantage of our concurrent FileSystem under the hood.

I was able to shrink the critical sections for these locks to be very small (it now just keeps track of how much data has been written, and readers use that to see if they've read it all).

Read calls are still sequenced with other reads (but not with Closed, so that you can 'cancel' a blocking read by closing, though concurrent read/close may cause a read to fail.

Writes are sequenced with Write/Close calls so they are safe for concurrent use still.

Concurrent Bug Fixes

Choose a tag to compare

@djherbis djherbis released this 04 Feb 06:37

Please Update to this Version!

Important Bug Fixes:

  • sync.Cond.Wait was not being called atomically. A Broadcast() could occur between RUnlock and Wait() therefore causing the Reader to miss a Write/Close event. If it happened on a Close() it would cause the Reader to block indefinitely. This has been resolved by making the Wait call atomic with RUnlock.
  • Stream.Close() now obtains the Write lock such that Broadcast() from a close will only occur while a Reader is Waiting or before a ReadAt call. It's also now safe to call with Write() as the documentation suggested. Though this could lead to a failed Write (on a closed file), but this is always true when closing/writing concurrently.

v1.0.0

Choose a tag to compare

@djherbis djherbis released this 25 Jan 02:04
updating readme