Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Releases: zio/zio

1.0.0-RC19-2

19 May 12:27
6a01052

Choose a tag to compare

This release is binary compatible with 1.0.0-RC19 and 1.0.0-RC19-1.

Notable changes:

1.0.0-RC19-1

19 May 07:19
0fa0811

Choose a tag to compare

ZIO 1.0.0-RC19-1 contains a few bugfixes for changes shipped in 1.0.0-RC19. It should be binary/source compatible with 1.0.0-RC19.

Notable changes:

1.0.0-RC19

16 May 06:21
4a20378

Choose a tag to compare

Another packed release! This version features tons of improvements to existing data types and exciting changes to ZIO Streams. Read on for more details!

A note on our roadmap

Although we've promised that RC18 would be the last (or one-before-last) release before the mythical 1.0.0 release, we've seen some regressions caused by the supervision changes introduced in RC18.

We have an exciting refinement to the model coming up in the following weeks. It is not included in this release, but will be included in the next one. Therefore, we anticipate that after RC19, we will release between 1-2 additional versions: one containing the supervision refinement, and optionally another release with follow-ups.

We appreciate your patience and help in using ZIO and sending feedback and bug reports!

Notable changes

ZIO Core

In this release a foldAll combinator has been added to ZRef that allows transforming a Ref by "zooming in" on one field in a case class or data structure. This allows Ref and friends to function as concurrent optics. A separate ZIO Optics library will be released in the near future with tools for doing this and ways to lift optics from existing libraries to work with ZRef.

ZIO Streams

This release features a major re-design to the ZIO Streams module:

  • All ZStream operators now work on chunks. Previously, to work with chunked streams, one would need to use ZStreamChunk. That data type is now deleted and instead all operators benefit from chunking automatically.

  • ZSink has been radically simplified.

    The previous implementation featured leftovers: a property made it possible to use ZSink as a streaming parser. We've come to realize that any parser implemented using ZSink's combinators is probably slow and inefficient compared to an actual parser library. Moreover, we would never be able to match the performance of parsing libraries while maintaining ZSink's generality.

    Instead, we've decided to re-focus ZSink on modeling aggregations and accumulations. It is now more limited, but more efficient and easier to use: the purpose of ZSink is to process a stream and emit one final result.

    If you've been using ZSink for aggregations (using ZSink.foldLeft and other operators), you should see little change to your code. In some cases, operators that were previously sinks have been migrated to ZTransducer - see next bullet point.

    For actual parsing usecases, stay tuned to the github.com/zio/zio-codecs project. Some exciting developments are in work there!

  • ZTransducer has been added to accomodate aggregations that emit multiple results.

    Whereas ZSink's purpose is to return one final result when processing a stream, there are several usecases where it makes sense to process a stream and emit multiple results. For example - collecting elements into batches of a certain size; weighted folds; etc.

    For these purposes, ZTransducer should now be used.

Big thanks to @regiskuckaertz and @simpadjo for their work on this re-design!

  • Add termination strategies for ZStream#merge (#3543) (by @luis3m)
  • Add ZStream#interruptAfter and ZStream#haltAfter (#3534) (by @luis3m)
  • Modify ZStream.fromQueue to no longer use singleton chunks (#3571) (by @luis3m)
  • Modify ZStream#toIterator to use chunks (#3569) (by @luis3m)
  • Add Transducer#zip (#3551) (by @simpadjo)
  • Implement ZStream#intersperse (#3514) (by @fagossa)
  • Fix ZStream.toInputStream handling of signed bytes (#3546) (by @lancelet)
  • add ZTransducer#mapOutput (#3523) (by @simpadjo)
  • Add ZTransducer.splitOn (#3519) (by @regiskuckaertz)
  • Add ZSink#mapError (#3501) (by @simpadjo)
  • Redesign ZStream as the ZConduit hierarchy (#3079) (by @iravid)
  • Add ZStream#haltWhen(IO) and ZStream#interruptWhen(IO) (#3306) (by @jeremyrsmith)
  • Add ZStream.fromIterator versions that capture exceptions. (#3195) (by @alexknvl)
  • ZStream error refinement. (#3196) (by @alexknvl)
  • Added drop and skip constructors. (#3190) (by @alexknvl)
  • Added ZStream.fromInputStreamEffect and ZStream.fromInputStreamManaged. (#3198) (by @alexknvl)

ZIO Test

In this release the implementation of TestClock has been updated. The concept of fiberTime has been eliminated. As a result, methods such as currentTime will always return the time that is set by the user using methods such as setTime. In addition, adjust will now suspend until all scheduled tasks have been completed. This should eliminate the need for external coordination such as promises and queues in most cases.

Read more

v1.0.0-RC18-2

11 Mar 23:46
38b0874

Choose a tag to compare

A minor release that fixes some issues identified in RC18:

  • Runtime#unsafeRunToFuture would auto-interrupt futures quickly due to supervision
  • There was no way to construct ZEnv outside ZLayer; now the default runtimes come equipped with ZEnv
  • The supervision model has been simplified (SuperviseMode is gone since it was redundant with other features)
  • Root fibers are now tracked weakly so are less prone to leaking
  • Some callback type signatures have been relaxed, to avoid forcing a return of Unit on the user
  • ZIO.adopt was added as the inverse of ZIO.disown
  • More scaladoc has been added
  • Parallel ZLayer construction is disabled until an issue with auto-killing is fixed
  • More combinators added to ZLayer, such as fail, orElse, orDie; and the Has constraint dropped on the output, required only for composition of layers
  • Mocking component in ZIO Test got a totally new overhaul that removes the need for implicits and allows many more powerful ways of creating expectations (all of, any of, etc.)

v1.0.0-RC18-1

03 Mar 22:55
9ee0e1c

Choose a tag to compare

Same as v1.0.0-RC18, fixing the missing documentation for ZLayer.

ZIO 1.0.0-RC18

03 Mar 17:48
511330d

Choose a tag to compare

ZIO 1.0.0-RC18 is the last expected release candidate for ZIO 1.0. There are no breaking changes between RC18 and 1.0, but no guarantees. The current plan is to release 1.0 within a few weeks after RC18, to ensure production-worthiness of 1.0.

Note: All deprecated methods will be deleted for ZIO 1.0.

ZIO Environment

Previously, the official recommended way to use ZIO Environment was to assemble pieces using inheritance to create larger environments out of smaller environments.

In the absence of proxies, this led to some pain around construction of the environment, because creating one class from other classes is not done using value-based operators, but inheritance-specific language features that do not permit abstraction.

Moreover, this approach had several drawbacks:

  • Providing just part of an environment was difficult, and was not possible to do generically (the remaining part of the environment had to be known statically).
  • It was not possible to dynamically update parts of the environment inside scoped regions, which led to pain when trying to customize services in parts of the application.

Finally, the principal way to make a first service depend on a second service was to list a reference to the second service inside the first (recalling the Cake Pattern self-type). This led to a pattern whereby business logic would express its dependencies by using ZIO Environment, but all other parts of the application would express their dependencies using fields.

These problems have been solved in RC18 with the introduction of two new data types: Has and ZLayer. Together they have led to a new pattern of encoding environmental dependencies, which has been rolled out in ZIO Core services (Clock, Console, Random, System).

While it is still technically possible to use the older pattern, the official ZIO ecosystem (all projects in the ZIO organization on Github) will be migrated to the new pattern.

Has

The new recommended way to assemble environments involves using a new structure called Has. The Has data type has operators for building bigger environments out of smaller environments, including add, which adds a service to a Has, and concat, which merges two Has into one.

ZLayer

ZLayer is a value that represents a recipe for constructing some services in terms of other services. It is similar to a constructor in a Java or Scala application, which takes the services it depends on, and returns the service it constructs (constructor-based dependency injection). Unlike constructors, however, ZLayers are first-class values that compose type-safely in several ways, and they can construct many services, not just one. Additionally, they can describe the effectful and resourceful construction, such as connecting to a database, creating a database thread pool, and when the service is no longer required, freeing the thread pool, and disconnecting from the database.

ZLayer represents the most power you could ever want in describing the construction of a service. In the end, almost all applications need something with this power (as witnessed by the fact that, generally, users of previous ZIO versions resorted to building the environment using ZManaged).

ZLayers can be constructed using a variety of constructors in the companion object of ZLayer. They can be composed horizontally (when one service depends on another), and vertically (for two independent services). Services that are repeated in the graph are automatically shared, to avoid duplicate construction and release. Further, services that can be constructed in parallel are automatically constructed in parallel, to optimize service construction time.

The general pattern of ZIO Environment is now as follows:

type UserRepo = Has[UserRepo.Service]
object UserRepo {
  trait Service { def getUserById(id: Id): Task[User] }

  def getUserById(id: Id): RIO[UserRepo, User] = ZIO.accessM(_.get.getUserById(id))
}

Then typically, a live value is placed in the companion object of the service, which uses ZLayer to construct a production version of the service in terms of its dependencies:

val live: ZLayer[Database, Nothing, UserRepo] = ???

Services may be provided to effects that need them using the ZIO#provideLayer method, e.g. myEffect.provideLayer(UserRepo.live).

ZIO Runtime System

Weak automatic supervision

Supervision is now backed by weak sets, which means that child fibers may be freely garbage collected when they cannot resume. This should address memory leaks in scenarios where large numbers of non-terminating fibers are created.

Structured concurrency

All child fibers are automatically bound to their parent fiber. When the parent fiber exits, the child fiber will be interrupted or disowned, as determined by the SuperviseMode it is forked with. The default supervision mode for forked fibers is interruption, which means that by default, when a parent fiber exits, its child fibers will be interrupted. This ensures fibers do not leak.

In order to recapture the previous behavior, one may use forkDaemon, or disown, which explicitly disowns a child fiber and moves it to a root set of fibers.

Safer race

Race no longer forces either side to be interruptible. Users may have to perform left.interruptible.race(right.interruptible) to acquire the old behavior (which punched holes in uninterruptible regions); or possibly, left.disconnect.race(right.disconnect) (if they want the effects to be keep running when interrupted, but in the background).

New combinators

Several new combinators are added:
disconnect — disconnects interruption of the effect from its parent. This allows "early interruption" without waiting for finalization. It replaces the need for all xyzFork variants, which are now deprecated. It's quite useful with race, with or without interruptible.
disown — Called by a parent fiber to disown a child fiber. Relocates the child to the root set.

New ZIO.never

When ZIO.never is forked, it will be garbage collected, so ZIO.never.onInterrupt(putStrLn("Bye")) will never execute the finalizer. This can be inconvenient for testing, so ZIO.infinity is added which is like never, but won't be garbage collected.

Deletion of Daemon Mode

Daemon mode has been deleted because in practice, code never knows whether grandchildren should be daemons, only whether immediate children should be daemons; and generally, daemon mode is a one-off for a specific forked fiber.

In place of daemon mode, effect.forkDaemon can be used, which is the composition of two other operators: ordinary fork, followed by an immediate disown of the child fiber.

Deprecation of *Fork Variations

All xyzFork variants are deprecated or removed. For example, bracketFork. This is thanks to the new disconnect operator which allows for a much more compositional approach to solving this problem. Now if you don't want interruption of something to wait around for completion, just use effect.disconnect.

Performance enhancements for blocking effects

Blocking effects has seen several enhancement regarding performance, with potential change in semantic:

  • Now, calling lock on a fiber first checks to see if the fiber is already on the correct Executor and does nothing if in that case;
  • effectBlocking doesn’t interrupt the underlying thread anymore in case of fiber interruption. If you want to revert to previous behavior, use effectBlockingInterrupt.
  • Blocking executor ergonomics were updated to enhance thread reuse and limit risk to crash the server in case of massive thread leak.

ZIO General API

Laziness

Effect constructors are now lazy. This is done to ensure that if users embed side-effects in unexpected places, then errors are managed by ZIO.

Deprecated traverse/sequence

Rather than have duplicate names for operators, the decision was made to deprecate the "classic names" for traverse/sequence, in favor of friendlier and more descriptive names foreach/collectAll.

ZIO Test

Inheritance Based Specs

Spes are now defined by inheriting from DefaultRunnableSpec instead of using constructor arguments:

object ExampleSpec extends DefaultRunnableSpec {
  
  def spec = suite(“ExampleSpec)(
    test(“addition works”) {
      assert(1 + 1)(equalTo(2))
    }
  )
}

This provides a more natural syntax for writing tests and allows defining data or helper methods in the same object instead of requiring a separate utility object.

Type Safe Equality

To provide increased type safety, the syntax for assertions has changed from assert(1 + 1, equalTo(2)) to assert(1 + 1)(equalTo(2)). This curried syntax allows the test framework to issue a compilation error if an equality assertion is comparing two unrelated types, catching bugs earlier. A ScalaFix migration rule is provided to automatically rewrite assertions to the new curried syntax.

Improved Test Console Behavior

To facilitate debugging, by default the TestConsole will now render output to the standard output in addition to writing it to the output buffer. This feature is configurable on a scoped basis using the debug and silent methods on TestConsole or the corresponding test aspects.

Test Annotations

Test annotations provide flexible information for reporting metadata about tests. ZIO Test ships with a variety of test annotations that will automatically track metrics such as the number of ignored tests, the number of times a test was retried using flaky and the number of times a test was repeated using nonFlaky. Users can apply additional annotations using test aspects, for example timing the execution of tests and showing the slowest tests using timed or labeling tests with tag.

In the future test annotations ...

Read more

1.0.0-RC17

18 Nov 00:21

Choose a tag to compare

Notable changes

This release contains major changes related to how fiber supervision is working.
The new behavior is that a fiber will automatically be interrupted when its parent fiber is interrupted. To make forked fibers independent of their parents, use .daemon.
Previously existing interruptChildren, supervised, unsupervised, checkSupervised, superviseStatus have been removed in favor of daemon, nonDaemon, checkDaemon and daemonStatus.

ZIO

  • Complete overhaul of supervision (#2169) by @jdegoes
  • Add fiber dumps with pretty printing for easier diagnostics (#2228) by @jdegoes
  • Add a new implicit instance CanFail[E] which provides implicit evidence that an effect with an error type E can fail, that is that E is not equal to Nothing. Requires such evidence to exist for ZIO combinators such as orElse that only make sense if an effect can fail (#2049) by @adamgfraser
  • Similarly, implements NeedsEnv so that useless combinators involving effects that don't require an environment don't compile (#2065) by @adamgfraser
  • Add ZIO.fromFunctionFuture (#1961) by @jczuchnowski
  • effectAsync should not resume fiber twice after interruption (#1939) by @darl
  • Add withFilter (#2114) by @wi101
  • Use URIO in type signatures where possible (#2092) by @joroKr21
  • Add ZIO#doUntil and ZIO#doWhile (#2147) by @adamgfraser
  • Ignore should not recover from unchecked exceptions (#2148) by @alexvanolst
  • Reimplement RaceWith in the ZIO runloop for better performance (#2091) by @YuvalItzchakov
  • Adapt ZIO.someOrFailException to improve interop with error types (#2087) by @mlangc
  • Fix Cause Definition of Equals and HashCode (#2220) by @adamgfraser
  • Improve implementation of InterruptStatus#isInterruptible (#2188) by @sirthias

ZIO Stream

ZIO Test

STM

Schedule

ZManaged

Chunk

Semaphore

  • Deprecate acquire, acquireN, release, releaseN in favor of withPermits (#1523) by @adamgfraser

Duration

1.0.0-RC16

28 Oct 20:35

Choose a tag to compare

Notable changes

ZIO

ZIO Stream

ZIO Test

In this release, the mocking framework API has gone through complete overhaul to be more concise and feature better type inference. Notable changes:

  • The capability tags for default mock services are moved directly to modules companion object. Use MockClock.nanoTime instead of MockClock.Service.nanoTime;
  • The expectations are now methods on capability tags. Use MockRandom.nextInt._0(equalTo(1)) returns value(42) instead of MockSpec.expect_(MockRandom.Service.nextInt._0)(equalTo(1))(42);
  • Assertions for input are now passed as arguments, e.g. MockConsole.putStrLn(equalTo("foo")) returns unit;
  • Stubbing returns is done via static methods value, valueF, valueM, failure, failureF, failureM, unit, and never in zio.test.mock.Expectation;
  • Dummy services (expecting no calls) are constructed using a static method nothing from zio.test.mock.Expectation. For example, val dummyConsole = Expectation.nothing[MockConsole];
  • The conversion to managed mock service is automatic and does not require any imports or type hints.

For more examples, see MockingExampleSpec.

Additional changes:

1.0.0-RC15

15 Oct 18:21

Choose a tag to compare

Notable changes

Build

ZIO, ZIO Test and ZIO Streams are now published for Dotty. This release builds against Dotty 0.19.

ZIO

  • Make ZIO#asError argument by-name to match ZIO#as by @neko-kai (#1905)
  • Rename Chunk#notEmpty to nonEmpty, add Chunk#size by @iravid (#1913)
  • Add ZEnv - a convenient definition for the standard ZIO environment by @mschuwalow (#1915)
  • Add mapping functions for ZEnv's components by @mschuwalow (#1957)
  • Add Promise#completeWith and memoize the IO passed to Promise#complete (semantics have changed here - take note if using Promise#complete) by @adamgfraser (#1954)
  • Reduce spurious FiberFailure warnings in built-in combinators by @adamgfraser (#1949)

ZIO Test

ZIO Streams

  • Add Stream.bracketExit by @vasilmkd (#1950)
  • Add Chunk#collectWhile, ZStreamChunk#collectWhile by @vasilmkd (#1945)
  • Eliminate space leaks with streams that concatenate infinitely (for example - ZStream.repeat) by @iravid (#1952)

v1.0.0-RC14

04 Oct 12:39

Choose a tag to compare

Notable changes

ZIO

ZIO Test

In this release the internal representation of Spec has been changed to make all Specs effectual. This allows for performing effects on groups of tests in additional to individual tests. We expect this will not require any changes from most users but may be breaking for code that relies on some methods on Spec or the particular encoding of ZSpec. Please report any issues you notice!

ZIO Stream

Documentation