A ZChannel[In, Env, Err, Out, Z]
is a nexus of I/O operations, which
supports both reading and writing. A channel may read values of type In
and
write values of type Out
. When the channel finishes, it yields a value of
type Z
. A channel may fail with a value of type Err
.
Channels are the foundation of ZIO Streams: both streams and sinks are built on channels. Most users shouldn't have to use channels directly, as streams and sinks are much more convenient and cover all common use cases. However, when adding new stream and sink operators, or doing something highly specialized, it may be useful to use channels directly.
Channels compose in a variety of ways:
- Piping. One channel can be piped to another channel, assuming the input type of the second is the same as the output type of the first.
- Sequencing. The terminal value of one channel can be used to create another channel, and both the first channel and the function that makes the second channel can be composed into a channel.
- Concating. The output of one channel can be used to create other channels, which are all concatenated together. The first channel and the function that makes the other channels can be composed into a channel.
- Companion:
- object
Value members
Concrete methods
Returns a new channel that is the sequential composition of this channel and the specified channel. The returned channel terminates with the terminal value of the other channel.
Returns a new channel that is the sequential composition of this channel and the specified channel. The returned channel terminates with the terminal value of the other channel.
This is a symbol operator for ZChannel#zipRight.
Returns a new channel that is the sequential composition of this channel and the specified channel. The returned channel terminates with the terminal value of this channel.
Returns a new channel that is the sequential composition of this channel and the specified channel. The returned channel terminates with the terminal value of this channel.
This is a symbol operator for ZChannel#zipLeft.
Returns a new channel that is the sequential composition of this channel and the specified channel. The returned channel terminates with a tuple of the terminal values of both channels.
Returns a new channel that is the sequential composition of this channel and the specified channel. The returned channel terminates with a tuple of the terminal values of both channels.
This is a symbol operator for ZChannel#zip.
Returns a new channel that pipes the output of this channel into the specified channel. The returned channel has the input type of this channel, and the output type of the specified channel, terminating with the value of the specified channel.
Returns a new channel that pipes the output of this channel into the specified channel. The returned channel has the input type of this channel, and the output type of the specified channel, terminating with the value of the specified channel.
This is a symbolic operator for ZChannel#pipeTo.
Returns a new channel that is the same as this one, except the terminal value of the channel is the specified constant value.
Returns a new channel that is the same as this one, except the terminal value of the channel is the specified constant value.
This method produces the same result as mapping this channel to the specified constant value.
Returns a new channel that is the same as this one, except if this channel errors for any typed error, then the returned channel will switch over to using the fallback channel returned by the specified error handler.
Returns a new channel that is the same as this one, except if this channel errors for any typed error, then the returned channel will switch over to using the fallback channel returned by the specified error handler.
Returns a new channel that is the same as this one, except if this channel errors for any cause at all, then the returned channel will switch over to using the fallback channel returned by the specified error handler.
Returns a new channel that is the same as this one, except if this channel errors for any cause at all, then the returned channel will switch over to using the fallback channel returned by the specified error handler.
Returns a new channel, which is the same as this one, except its outputs are filtered and transformed by the specified partial function.
Returns a new channel, which is the same as this one, except its outputs are filtered and transformed by the specified partial function.
Returns a new channel whose outputs are fed to the specified factory function, which creates new channels in response. These new channels are sequentially concatenated together, and all their outputs appear as outputs of the newly returned channel.
Returns a new channel whose outputs are fed to the specified factory function, which creates new channels in response. These new channels are sequentially concatenated together, and all their outputs appear as outputs of the newly returned channel.
Returns a new channel whose outputs are fed to the specified factory function, which creates new channels in response. These new channels are sequentially concatenated together, and all their outputs appear as outputs of the newly returned channel. The provided merging function is used to merge the terminal values of all channels into the single terminal value of the returned channel.
Returns a new channel whose outputs are fed to the specified factory function, which creates new channels in response. These new channels are sequentially concatenated together, and all their outputs appear as outputs of the newly returned channel. The provided merging function is used to merge the terminal values of all channels into the single terminal value of the returned channel.
Returns a new channel whose outputs are fed to the specified factory function, which creates new channels in response. These new channels are sequentially concatenated together, and all their outputs appear as outputs of the newly returned channel. The provided merging function is used to merge the terminal values of all channels into the single terminal value of the returned channel.
Returns a new channel whose outputs are fed to the specified factory function, which creates new channels in response. These new channels are sequentially concatenated together, and all their outputs appear as outputs of the newly returned channel. The provided merging function is used to merge the terminal values of all channels into the single terminal value of the returned channel.
Returns a new channel, which is the concatenation of all the channels that are written out by this channel. This method may only be called on channels that output other channels.
Returns a new channel, which is the concatenation of all the channels that are written out by this channel. This method may only be called on channels that output other channels.
Returns a new channel, which is the same as this one, except that all the outputs are collected and bundled into a tuple together with the terminal value of this channel.
Returns a new channel, which is the same as this one, except that all the outputs are collected and bundled into a tuple together with the terminal value of this channel.
As the channel returned from this channel collects all of this channel's output into an in- memory chunk, it is not safe to call this method on channels that output a large or unbounded number of values.
Returns a new channel which reads all the elements from upstream's output channel and ignores them, then terminates with the upstream result value.
Returns a new channel which reads all the elements from upstream's output channel and ignores them, then terminates with the upstream result value.
Returns a new channel that collects the output and terminal value of this channel, which it then writes as output of the returned channel.
Returns a new channel that collects the output and terminal value of this channel, which it then writes as output of the returned channel.
Returns a new channel with an attached finalizer. The finalizer is guaranteed to be executed so long as the channel begins execution (and regardless of whether or not it completes).
Returns a new channel with an attached finalizer. The finalizer is guaranteed to be executed so long as the channel begins execution (and regardless of whether or not it completes).
Returns a new channel, which sequentially combines this channel, together with the provided factory function, which creates a second channel based on the terminal value of this channel. The result is a channel that will first perform the functions of this channel, before performing the functions of the created channel (including yielding its terminal value).
Returns a new channel, which sequentially combines this channel, together with the provided factory function, which creates a second channel based on the terminal value of this channel. The result is a channel that will first perform the functions of this channel, before performing the functions of the created channel (including yielding its terminal value).
Returns a new channel, which flattens the terminal value of this channel. This function may only be called if the terminal value of this channel is another channel of compatible types.
Returns a new channel, which flattens the terminal value of this channel. This function may only be called if the terminal value of this channel is another channel of compatible types.
Returns a new channel, which is the same as this one, except it will be interrupted when the specified effect completes. If the effect completes successfully before the underlying channel is done, then the returned channel will yield the success value of the effect as its terminal value. On the other hand, if the underlying channel finishes first, then the returned channel will yield the success value of the underlying channel as its terminal value.
Returns a new channel, which is the same as this one, except it will be interrupted when the specified effect completes. If the effect completes successfully before the underlying channel is done, then the returned channel will yield the success value of the effect as its terminal value. On the other hand, if the underlying channel finishes first, then the returned channel will yield the success value of the underlying channel as its terminal value.
Returns a new channel, which is the same as this one, except it will be interrupted when the specified promise is completed. If the promise is completed before the underlying channel is done, then the returned channel will yield the value of the promise. Otherwise, if the underlying channel finishes first, then the returned channel will yield the value of the underlying channel.
Returns a new channel, which is the same as this one, except it will be interrupted when the specified promise is completed. If the promise is completed before the underlying channel is done, then the returned channel will yield the value of the promise. Otherwise, if the underlying channel finishes first, then the returned channel will yield the value of the underlying channel.
Returns a new channel, which is the same as this one, except the terminal value of the returned channel is created by applying the specified function to the terminal value of this channel.
Returns a new channel, which is the same as this one, except the terminal value of the returned channel is created by applying the specified function to the terminal value of this channel.
Returns a new channel, which is the same as this one, except the failure value of the returned channel is created by applying the specified function to the failure value of this channel.
Returns a new channel, which is the same as this one, except the failure value of the returned channel is created by applying the specified function to the failure value of this channel.
Returns a new channel, which is the same as this one, except the terminal value of the returned channel is created by applying the specified effectful function to the terminal value of this channel.
Returns a new channel, which is the same as this one, except the terminal value of the returned channel is created by applying the specified effectful function to the terminal value of this channel.
Returns a new channel, which is the merge of this channel and the specified
channel, where the behavior of the returned channel on left or right early
termination is decided by the specified leftDone
and rightDone
merge
decisions.
Returns a new channel, which is the merge of this channel and the specified
channel, where the behavior of the returned channel on left or right early
termination is decided by the specified leftDone
and rightDone
merge
decisions.
Returns a new channel that will perform the operations of this one, until failure, and then it will switch over to the operations of the specified fallback channel.
Returns a new channel that will perform the operations of this one, until failure, and then it will switch over to the operations of the specified fallback channel.
Provides the channel with its required environment, which eliminates its
dependency on Env
.
Provides the channel with its required environment, which eliminates its
dependency on Env
.
Provides a layer to the channel, which translates it to another level.
Provides a layer to the channel, which translates it to another level.
Transforms the environment being provided to the channel with the specified function.
Transforms the environment being provided to the channel with the specified function.
Splits the environment into two parts, providing one part using the
specified layer and leaving the remainder Env0
.
Splits the environment into two parts, providing one part using the
specified layer and leaving the remainder Env0
.
Updates a service in the environment of this channel.
Updates a service in the environment of this channel.
Updates a service at the specified key in the environment of this channel.
Updates a service at the specified key in the environment of this channel.