Releases: typelevel/fs2
v3.0.6
Supports Cats Effect 3 and built for Scala 2.12, 2.13, and 3 final.
Fixes:
- Fixed regression in
readOutputStream(#2459) - Fix TLS socket read stall immediately after handshake (#2461)
- Avoid allocations in TLSEngine when logging is disabled (#2462)
Improvements:
- Add
Pull.sleep(#2456)
Acknowledgments
➜ git shortlog -sn --no-merges "v3.0.5".."v3.0.6"
3 Vasil Vasilev
2 Michael Pilquist
1 Diego E. Alonso Blas
1 Scala Steward
1 nikiforo
v2.5.8
v3.0.5
Supports Cats Effect 3 and built for Scala 2.12, 2.13, and 3 final.
Fixes:
- Fixed thread handling gotcha when using readOutputStream (#2037 #2383)
- Fixed bug in
slidingthat delayed output by a chunk (#2428) - Fixed a bug in
TLSContext.insecurewhere TLS sessions would fail with NPE (#2431) - Fixed TCP socket options to server and client sockets get correct options (#2421)
Improvements:
- Simplified implementation of
zipWithAll(#2452) - Add partial apply factory for SignallingRef (#2406)
- Internal interpreter simplifications (#2445 #2433 #2416 #2430 #2417)
Acknowledgments
➜ git shortlog -sn --no-merges "v3.0.4".."v3.0.5"
24 Vasil Vasilev
12 Scala Steward
6 Diego E. Alonso Blas
4 Erlend Hamnaberg
1 Arman Bilge
1 jilen
1 Artem Nikiforov
1 Ivan V. Smirnov
1 Michael Pilquist
v2.5.7
Supports Cats Effect 2 and built for Scala 2.12, 2.13, and 3 final.
Fixes:
- Fixes thread handling gotcha when using
readOutputStream(#2037 #2383 #2446) (fixed by @vasilmkd and back ported from 3.0 by @bpholt) - Various build cleanup and warning cleanup
Acknowledgments
➜ git shortlog -sn --no-merges "v2.5.6".."v2.5.7"
10 Vasil Vasilev
v3.0.4
Supports Cats Effect 3 and built for Scala 2.12, 2.13, and 3 final.
Fixes:
- Fixed memory leak in
Channelwhich also impactedmergeand other concurrent combinators (#2408)
Acknowledgments
➜ git shortlog -sn --no-merges "v3.0.3".."v3.0.4"
2 Scala Steward
1 Diego E. Alonso Blas
1 Jens Halm
1 Juraj
1 Michael Pilquist
1 Rehan Mahmood
1 nikiforo
v3.0.3
Supports Cats Effect 3 and built for Scala 2.12, 2.13, and 3 final.
Fixes:
- Fixed memory leak in
Stream#map(#2394) - Fixed bug in file watching support when watching multiple files in same directory (#2375)
- Fixed bug in
fixedRateand derived operations where dampening was not working (#2386) - Fixed
ClassCastExceptioninChunk(#2380)
New Features:
- Added
fs2.io.net.unixsocketpackage to fs2-io, providing support for working with unix domain sockets. Supports both JEP380 (if running on JDK16+) or JNR (if dependency is added to class path) (#2376) - Added
Stream#meteredStartImmediately(#2369) - Added
Pull.loopEither(#2368)
Performance
- Reimplemented
readOutputStreamto avoid using JDKPiped{Input/Output}Stream(#2383)
Acknowledgments
➜ git shortlog -sn --no-merges "v3.0.2".."v3.0.3"
36 Vasil Vasilev
24 Michael Pilquist
6 Christopher Davenport
6 Scala Steward
2 shogan
2 Pau Alarcón
2 nikiforo
1 Hugo van Rijswijk
1 Fabio Labella
1 Diego E. Alonso Blas
1 Rehan Mahmood
v2.5.6
v3.0.2
Built for Scala 2.12, 2.13, and 3.0.0-RC2/RC3.
Fixes:
- Fixed stack safety of
Stream#map(#2354)
Documentation:
- Clarified proper use of TLS servers and socket connection handling (#2358)
Acknowledgments
➜ git shortlog -sn --no-merges "v3.0.0".."v3.0.2"
9 Scala Steward
5 Michael Pilquist
4 Tim Spence
1 Ross A. Baker
1 William Narmontas
v2.5.5
v3.0.0
FS2 3.0.0 is the first official release built for Cats Effect 3, focusing on integration with the new Cats Effect typeclasses and standard library.
Concurrency Support
The biggest API changes to FS2 are in the fs2.concurrent package:
- The
Queue(andInspectableQueue) types are gone in favor ofcats.effect.std.Queue(#2201) - There's a brand new implementation of
Topicwhich no longer requires an initial element and is significantly faster. (#2252) - There's a
Channeltype -- a multiple producer, single consumer concurrency primitive (#2326) - Support for fanout via broadcast operations has been revamped and simplified (#2312)
- Support for balanced fanout has been removed, though it may return in a future release (#2340)
- The experimental
PubSubtype has been removed - There's a new
TimedPullAPI which allows simpler implementations of custom pulls that timeout while awaiting elements (#2062) - There's a new implementation of
groupWithinwhich is significantly faster (#2327)
Core Changes
One of the most exciting changes yet least visible changes in FS2 3.0.0 is the new interpreter. Stream compilation and evaluation is now handled by the Pull type thanks primarily to the work of @diesalbla. This new interpreter is much easier to work with than the old FreeC based implementation.
Another notable change to core APIs is that they no longer take Sync constraints. Instead, they take the least powerful type class or capability trait possible. For example, Stream.duration requires a Clock[F] constraint instead of Sync[F].
No More Blocker
The cats.effect.Blocker type was removed in CE 3 -- instead, Sync[F] supports blocking calls via Sync[F].blocking(thunk). As a result, FS2 APIs that took a Blocker have been simplified and in some cases, operations have been combined (e.g., lines & linesAsync have been combined to just lines).
Sinks
The deprecated Sink trait has finally been removed and we now represent sinks via a stream transformation that discards all output values -- Stream[F, O] => Stream[F, Nothing] aka Pipe[F, O, Nothing]. This is different than the old definition of Sink which emitted an undefined number of Unit values -- and as a result of the behavior being undefined, implementations varied widely. Implementations included emitting:
- 0 unit values
- 1 unit at termination of the source stream
- 1 unit per output element from source stream
- 1 unit per output chunk from source stream
- etc.
There are a few ergonomic improvements related to the new encoding of sinks:
Stream.exec(IO.println(...))-Stream.exectakes anF[Unit]and returns aStream[F, Nothing]Stream(1, 2, 3).foreach(IO.println)- Theforeachmethod onStreamtakes aO => F[Unit]and returns aStream[F, Nothing]s.unitary- Theunitarymethod onStreamconverts aStream[F, Nothing]to aStream[F, Unit]which emits a single unit at termination ofs- Calling
flatMapon aStream[F, Nothing]no longer compiles, which avoids mistakes that result in unexpected behavior.
Capability Traits
The fs2-io project provides support for working with files and networks, abstracting the Java NIO APIs. The implementations require either Async[F] or Sync[F] depending on whether the underlying NIO API is non-blocking or blocking.
One of the main features of CE3 is the position of the Sync and Async type classes in the hierarchy. As the most powerful type classes, they are now firmly at the bottom of the hierarchy. To avoid requiring Sync / Async constraints in code that uses fs2-io, we are adding capability traits -- traits which limit the capabilities of an effect to a discrete set of operations. The new fs2.io.file.Files[F] capability trait provides the ability to work with files in the effect F. For example:
def readAllText[F[_]: Files](directory: Path): Stream[F, String] =
Files[F].directoryStream(directory).flatMap { f =>
Files[F].readAll(f, 1024*1024)
.through(text.utf8Decode)
.through(text.lines)
}The readAllText method takes a Files[F] capability instead of an Async[F], providing better parametric reasoning.
FS2 ships with some other capability traits:
fs2.io.net.Network-- revamped support for TCP, UDP, and TLS, built on Java NIO and ip4sfs2.compression.Compression-- support for deflate and gzip
Stream Compilation
Streams are converted to effects via expressions like s.compile.toList and s.compile.drain. Calling s.compile on a Stream[F, O] requires an implicit Compiler[F, X] (where X is chosen based on the type of compilation requested).
In FS2 2.x, getting a Compiler[F, X] instance for the effect F generally required a Sync[F] (this is not true for the Pure and Fallible effects but is otherwise accurate). In FS2 3, compilation now only requires a Concurrent[F]. If a Concurrent[F] is not available, then compilation falls back to using a Sync[F] -- this allows stream compilation for effects like SyncIO which do not have a Concurrent instance.
In a polymorphic context, compilation is supported by either adding a Concurrent[F] constraint, or if compilation of non-concurrent effects is needed as well, a Compiler.Target constraint:
import fs2.{Compiler, Stream}
import cats.effect.Concurrent
// Allows compilation for any Concurrent[F] but not for things like SyncIO
def compileThis[F[_]: Concurrent, O](f: Stream[F, O]): F[Unit] = f.compile.drain
// Allows compilation for any Concurrent[F] or any Sync[F]
def compileThat[F[_]: Compiler.Target, O](f: Stream[F, O]): F[Unit] = f.compile.drainAcknowledgements
FS2 3.0.0 has been in the making for over a year and is the work of many individuals. Thanks to everyone who has contributed ideas, discussions, pull requests, etc.
➜ git shortlog -sn --no-merges "v2.5.3".."v3.0.0"
375 Fabio Labella
135 Michael Pilquist
114 mpilquist
50 Diego E. Alonso Blas
21 Scala Steward
19 nikiforo
11 anikiforov
10 LLCampos
9 Domas Poliakas
6 Dmitry Golubets
5 Diego E. Alonso-Blas
5 Raas Ahsan
2 Ben Plommer
1 Daniel Spiewak
1 Luís Campos
1 Niklas Klein
1 Luis Martinez
1 Rafał Krzewski
1 Rob Norris
1 Robert Marek
1 Ryan Peters
1 Lars Hupel
1 Zach McCoy
1 agadek
1 Kirill
1 Georgi Krastev
1 Martins Purins