- Companion:
- object
Value members
Concrete methods
Returns a stream that submerges the error case of an Either
into the
ZStream
.
Returns a stream that submerges the error case of an Either
into the
ZStream
.
Aggregates elements of this stream using the provided sink for as long as the downstream operators on the stream are busy.
Aggregates elements of this stream using the provided sink for as long as the downstream operators on the stream are busy.
This operator divides the stream into two asynchronous "islands". Operators upstream of this operator run on one fiber, while downstream operators run on another. Whenever the downstream fiber is busy processing elements, the upstream fiber will feed elements into the sink until it signals completion.
Any sink can be used here, but see ZSink.foldWeightedZIO and ZSink.foldUntilZIO for sinks that cover the common usecases.
Like aggregateAsyncWithinEither
, but only returns the Right
results.
Like aggregateAsyncWithinEither
, but only returns the Right
results.
- Value parameters:
- schedule
signalling for when to stop the aggregation
- sink
used for the aggregation
- Returns:
ZStream[R1, E2, B]
Aggregates elements using the provided sink until it completes, or until the delay signalled by the schedule has passed.
Aggregates elements using the provided sink until it completes, or until the delay signalled by the schedule has passed.
This operator divides the stream into two asynchronous islands. Operators upstream of this operator run on one fiber, while downstream operators run on another. Elements will be aggregated by the sink until the downstream fiber pulls the aggregated value, or until the schedule's delay has passed.
Aggregated elements will be fed into the schedule to determine the delays between pulls.
- Value parameters:
- schedule
signalling for when to stop the aggregation
- sink
used for the aggregation
- Returns:
ZStream[R1, E2, Either[C, B]]
Maps the success values of this stream to the specified constant value.
Maps the success values of this stream to the specified constant value.
Reads the first n values from the stream and uses them to choose the pipeline that will be used for the remainder of the stream.
Reads the first n values from the stream and uses them to choose the pipeline that will be used for the remainder of the stream.
Fan out the stream, producing a list of streams that have the same elements
as this stream. The driver stream will only ever advance the maximumLag
chunks before the slowest downstream stream.
Fan out the stream, producing a list of streams that have the same elements
as this stream. The driver stream will only ever advance the maximumLag
chunks before the slowest downstream stream.
Fan out the stream, producing a dynamic number of streams that have the
same elements as this stream. The driver stream will only ever advance the
maximumLag
chunks before the slowest downstream stream.
Fan out the stream, producing a dynamic number of streams that have the
same elements as this stream. The driver stream will only ever advance the
maximumLag
chunks before the slowest downstream stream.
Converts the stream to a scoped list of queues. Every value will be
replicated to every queue with the slowest queue being allowed to buffer
maximumLag
chunks before the driver is back pressured.
Converts the stream to a scoped list of queues. Every value will be
replicated to every queue with the slowest queue being allowed to buffer
maximumLag
chunks before the driver is back pressured.
Queues can unsubscribe from upstream by shutting down.
Converts the stream to a scoped dynamic amount of queues. Every chunk will
be replicated to every queue with the slowest queue being allowed to buffer
maximumLag
chunks before the driver is back pressured.
Converts the stream to a scoped dynamic amount of queues. Every chunk will
be replicated to every queue with the slowest queue being allowed to buffer
maximumLag
chunks before the driver is back pressured.
Queues can unsubscribe from upstream by shutting down.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
elements in a queue.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
elements in a queue.
- Note:
This combinator destroys the chunking structure. It's recommended to use rechunk afterwards.
Prefer capacities that are powers of 2 for better performance.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
chunks in a queue.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
chunks in a queue.
- Note:
Prefer capacities that are powers of 2 for better performance.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
chunks in a dropping queue.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
chunks in a dropping queue.
- Note:
Prefer capacities that are powers of 2 for better performance.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
chunks in a sliding queue.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
chunks in a sliding queue.
- Note:
Prefer capacities that are powers of 2 for better performance.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
elements in a dropping queue.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
elements in a dropping queue.
- Note:
This combinator destroys the chunking structure. It's recommended to use rechunk afterwards.
Prefer capacities that are powers of 2 for better performance.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
elements in a sliding queue.
Allows a faster producer to progress independently of a slower consumer by
buffering up to capacity
elements in a sliding queue.
- Note:
This combinator destroys the chunking structure. It's recommended to use rechunk afterwards.
Prefer capacities that are powers of 2 for better performance.
Allows a faster producer to progress independently of a slower consumer by buffering chunks into an unbounded queue.
Allows a faster producer to progress independently of a slower consumer by buffering chunks into an unbounded queue.
Switches over to the stream produced by the provided function in case this one fails with a typed error.
Switches over to the stream produced by the provided function in case this one fails with a typed error.
Switches over to the stream produced by the provided function in case this one fails. Allows recovery from all causes of failure, including interruption if the stream is uninterruptible.
Switches over to the stream produced by the provided function in case this one fails. Allows recovery from all causes of failure, including interruption if the stream is uninterruptible.
Switches over to the stream produced by the provided function in case this one fails with some typed error.
Switches over to the stream produced by the provided function in case this one fails with some typed error.
Switches over to the stream produced by the provided function in case this one fails with some errors. Allows recovery from all causes of failure, including interruption if the stream is uninterruptible.
Switches over to the stream produced by the provided function in case this one fails with some errors. Allows recovery from all causes of failure, including interruption if the stream is uninterruptible.
Returns a new stream that only emits elements that are not equal to the previous element emitted, using natural equality to determine whether two elements are equal.
Returns a new stream that only emits elements that are not equal to the previous element emitted, using natural equality to determine whether two elements are equal.
Returns a new stream that only emits elements that are not equal to the previous element emitted, using the specified function to determine whether two elements are equal.
Returns a new stream that only emits elements that are not equal to the previous element emitted, using the specified function to determine whether two elements are equal.
Returns a new stream that only emits elements that are not equal to the previous element emitted, using the specified effectual function to determine whether two elements are equal.
Returns a new stream that only emits elements that are not equal to the previous element emitted, using the specified effectual function to determine whether two elements are equal.
Exposes the underlying chunks of the stream as a stream of chunks of elements.
Exposes the underlying chunks of the stream as a stream of chunks of elements.
Transforms all elements of the stream for as long as the specified partial function is defined.
Transforms all elements of the stream for as long as the specified partial function is defined.
Terminates the stream when encountering the first Right
.
Terminates the stream when encountering the first Right
.
Terminates the stream when encountering the first Left
.
Terminates the stream when encountering the first Left
.
Terminates the stream when encountering the first None
.
Terminates the stream when encountering the first None
.
Terminates the stream when encountering the first Exit.Failure
.
Terminates the stream when encountering the first Exit.Failure
.
Effectfully transforms all elements of the stream for as long as the specified partial function is defined.
Effectfully transforms all elements of the stream for as long as the specified partial function is defined.
Performs an effectful filter and map in a single step.
Performs an effectful filter and map in a single step.
Combines the elements from this stream and the specified stream by
repeatedly applying the function f
to extract an element using both sides
and conceptually "offer" it to the destination stream. f
can maintain
some internal state to control the combining process, with the initial
state being specified by s
.
Combines the elements from this stream and the specified stream by
repeatedly applying the function f
to extract an element using both sides
and conceptually "offer" it to the destination stream. f
can maintain
some internal state to control the combining process, with the initial
state being specified by s
.
Where possible, prefer ZStream#combineChunks for a more efficient implementation.
Combines the chunks from this stream and the specified stream by repeatedly
applying the function f
to extract a chunk using both sides and
conceptually "offer" it to the destination stream. f
can maintain some
internal state to control the combining process, with the initial state
being specified by s
.
Combines the chunks from this stream and the specified stream by repeatedly
applying the function f
to extract a chunk using both sides and
conceptually "offer" it to the destination stream. f
can maintain some
internal state to control the combining process, with the initial state
being specified by s
.
Concatenates the specified stream with this stream, resulting in a stream that emits the elements from this stream and then the elements from the specified stream.
Concatenates the specified stream with this stream, resulting in a stream that emits the elements from this stream and then the elements from the specified stream.
Composes this stream with the specified stream to create a cartesian
product of elements. The that
stream would be run multiple times, for
every element in the this
stream.
Composes this stream with the specified stream to create a cartesian
product of elements. The that
stream would be run multiple times, for
every element in the this
stream.
See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
Composes this stream with the specified stream to create a cartesian
product of elements, but keeps only elements from this stream. The that
stream would be run multiple times, for every element in the this
stream.
Composes this stream with the specified stream to create a cartesian
product of elements, but keeps only elements from this stream. The that
stream would be run multiple times, for every element in the this
stream.
See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
Composes this stream with the specified stream to create a cartesian
product of elements, but keeps only elements from the other stream. The
that
stream would be run multiple times, for every element in the this
stream.
Composes this stream with the specified stream to create a cartesian
product of elements, but keeps only elements from the other stream. The
that
stream would be run multiple times, for every element in the this
stream.
See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
Composes this stream with the specified stream to create a cartesian
product of elements with a specified function. The that
stream would be
run multiple times, for every element in the this
stream.
Composes this stream with the specified stream to create a cartesian
product of elements with a specified function. The that
stream would be
run multiple times, for every element in the this
stream.
See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
Delays the emission of values by holding new values for a set duration. If no new values arrive during that time the value is emitted, however if a new value is received during the holding period the previous value is discarded and the process is repeated with the new value.
Delays the emission of values by holding new values for a set duration. If no new values arrive during that time the value is emitted, however if a new value is received during the holding period the previous value is discarded and the process is repeated with the new value.
This operator is useful if you have a stream of "bursty" events which eventually settle down and you only need the final event of the burst.
- Example:
A search engine may only want to initiate a search after a user has paused typing so as to not prematurely recommend results.
Taps the stream, printing the result of calling .toString
on the emitted
values.
Taps the stream, printing the result of calling .toString
on the emitted
values.
Taps the stream, printing the result of calling .toString
on the emitted
values. Prefixes the output with the given label.
Taps the stream, printing the result of calling .toString
on the emitted
values. Prefixes the output with the given label.
Produces the specified element if this stream is empty.
Produces the specified element if this stream is empty.
Produces the specified chunk if this stream is empty.
Produces the specified chunk if this stream is empty.
Switches to the provided stream in case this one is empty.
Switches to the provided stream in case this one is empty.
More powerful version of ZStream#broadcast
. Allows to provide a function
that determines what queues should receive which elements. The decide
function will receive the indices of the queues in the resulting list.
More powerful version of ZStream#broadcast
. Allows to provide a function
that determines what queues should receive which elements. The decide
function will receive the indices of the queues in the resulting list.
More powerful version of ZStream#distributedWith
. This returns a function
that will produce new queues and corresponding indices. You can also
provide a function that will be executed after the final events are
enqueued in all queues. Shutdown of the queues is handled by the driver.
Downstream users can also shutdown queues manually. In this case the driver
will continue but no longer backpressure on them.
More powerful version of ZStream#distributedWith
. This returns a function
that will produce new queues and corresponding indices. You can also
provide a function that will be executed after the final events are
enqueued in all queues. Shutdown of the queues is handled by the driver.
Downstream users can also shutdown queues manually. In this case the driver
will continue but no longer backpressure on them.
Converts this stream to a stream that executes its effects but emits no elements. Useful for sequencing effects using streams:
Converts this stream to a stream that executes its effects but emits no elements. Useful for sequencing effects using streams:
(Stream(1, 2, 3).tap(i => ZIO(println(i))) ++
Stream.fromZIO(ZIO(println("Done!"))).drain ++
Stream(4, 5, 6).tap(i => ZIO(println(i)))).run(Sink.drain)
Drains the provided stream in the background for as long as this stream is
running. If this stream ends before other
, other
will be interrupted.
If other
fails, this stream will fail with that error.
Drains the provided stream in the background for as long as this stream is
running. If this stream ends before other
, other
will be interrupted.
If other
fails, this stream will fail with that error.
Drops the specified number of elements from this stream.
Drops the specified number of elements from this stream.
Drops the last specified number of elements from this stream.
Drops the last specified number of elements from this stream.
- Note:
This combinator keeps
n
elements in memory. Be careful with big numbers.
Drops all elements of the stream until the specified predicate evaluates to
true
.
Drops all elements of the stream until the specified predicate evaluates to
true
.
Drops all elements of the stream for as long as the specified predicate
evaluates to true
.
Drops all elements of the stream for as long as the specified predicate
evaluates to true
.
Drops all elements of the stream for as long as the specified predicate
produces an effect that evalutates to true
Drops all elements of the stream for as long as the specified predicate
produces an effect that evalutates to true
- See also:
Returns a stream whose failures and successes have been lifted into an
Either
. The resulting stream cannot fail, because the failures have been
exposed as part of the Either
success case.
Returns a stream whose failures and successes have been lifted into an
Either
. The resulting stream cannot fail, because the failures have been
exposed as part of the Either
success case.
- Note:
the stream will end as soon as the first error occurs.
Executes the provided finalizer after this stream's finalizers run.
Executes the provided finalizer after this stream's finalizers run.
Filters the elements emitted by this stream using the provided function.
Filters the elements emitted by this stream using the provided function.
Filters this stream by the specified predicate, removing all elements for which the predicate evaluates to true.
Filters this stream by the specified predicate, removing all elements for which the predicate evaluates to true.
Effectfully filters the elements emitted by this stream.
Effectfully filters the elements emitted by this stream.
Finds the first element emitted by this stream that satisfies the provided predicate.
Finds the first element emitted by this stream that satisfies the provided predicate.
Finds the first element emitted by this stream that satisfies the provided effectful predicate.
Finds the first element emitted by this stream that satisfies the provided effectful predicate.
Emits elements of this stream with a fixed delay in between, regardless of how long it takes to produce a value.
Emits elements of this stream with a fixed delay in between, regardless of how long it takes to produce a value.
Returns a stream made of the concatenation in strict order of all the
streams produced by passing each element of this stream to f0
Returns a stream made of the concatenation in strict order of all the
streams produced by passing each element of this stream to f0
Maps each element of this stream to another stream and returns the
non-deterministic merge of those streams, executing up to n
inner streams
concurrently. Up to bufferSize
elements of the produced streams may be
buffered in memory by this operator.
Maps each element of this stream to another stream and returns the
non-deterministic merge of those streams, executing up to n
inner streams
concurrently. Up to bufferSize
elements of the produced streams may be
buffered in memory by this operator.
Maps each element of this stream to another stream and returns the
non-deterministic merge of those streams, executing up to n
inner streams
concurrently. When a new stream is created from an element of the source
stream, the oldest executing stream is cancelled. Up to bufferSize
elements of the produced streams may be buffered in memory by this
operator.
Maps each element of this stream to another stream and returns the
non-deterministic merge of those streams, executing up to n
inner streams
concurrently. When a new stream is created from an element of the source
stream, the oldest executing stream is cancelled. Up to bufferSize
elements of the produced streams may be buffered in memory by this
operator.
Flattens this stream-of-streams into a stream made of the concatenation in strict order of all the streams.
Flattens this stream-of-streams into a stream made of the concatenation in strict order of all the streams.
Submerges the chunks carried by this stream into the stream's structure, while still preserving them.
Submerges the chunks carried by this stream into the stream's structure, while still preserving them.
Submerges the iterables carried by this stream into the stream's structure, while still preserving them.
Submerges the iterables carried by this stream into the stream's structure, while still preserving them.
Flattens a stream of streams into a stream by executing a non-deterministic
concurrent merge. Up to n
streams may be consumed in parallel and up to
outputBuffer
elements may be buffered by this operator.
Flattens a stream of streams into a stream by executing a non-deterministic
concurrent merge. Up to n
streams may be consumed in parallel and up to
outputBuffer
elements may be buffered by this operator.
Like flattenPar, but executes all streams concurrently.
Like flattenPar, but executes all streams concurrently.
Consumes all elements of the stream, passing them to the specified callback.
Consumes all elements of the stream, passing them to the specified callback.
Creates a pipeline that groups on adjacent keys, calculated by function f.
Creates a pipeline that groups on adjacent keys, calculated by function f.
Partition a stream using a function and process each stream individually. This returns a data structure that can be used to further filter down which groups shall be processed.
Partition a stream using a function and process each stream individually. This returns a data structure that can be used to further filter down which groups shall be processed.
After calling apply on the GroupBy object, the remaining groups will be processed in parallel and the resulting streams merged in a nondeterministic fashion.
Up to buffer
elements may be buffered in any group stream before the
producer is backpressured. Take care to consume from all streams in order
to prevent deadlocks.
Example: Collect the first 2 words for every starting letter from a stream of words.
ZStream.fromIterable(List("hello", "world", "hi", "holla"))
.groupByKey(_.head) { case (k, s) => s.take(2).map((k, _)) }
.runCollect
.map(_ == List(('h', "hello"), ('h', "hi"), ('w', "world"))
Partitions the stream with specified chunkSize
Partitions the stream with specified chunkSize
- Value parameters:
- chunkSize
size of the chunk
Partitions the stream with the specified chunkSize or until the specified duration has passed, whichever is satisfied first.
Partitions the stream with the specified chunkSize or until the specified duration has passed, whichever is satisfied first.
Specialized version of haltWhen which halts the evaluation of this stream after the given duration.
Specialized version of haltWhen which halts the evaluation of this stream after the given duration.
An element in the process of being pulled will not be interrupted when the
given duration completes. See interruptAfter
for this behavior.
Halts the evaluation of this stream when the provided IO completes. The given IO will be forked as part of the returned stream, and its success will be discarded.
Halts the evaluation of this stream when the provided IO completes. The given IO will be forked as part of the returned stream, and its success will be discarded.
An element in the process of being pulled will not be interrupted when the
IO completes. See interruptWhen
for this behavior.
If the IO completes with a failure, the stream will emit that failure.
Halts the evaluation of this stream when the provided promise resolves.
Halts the evaluation of this stream when the provided promise resolves.
If the promise completes with a failure, the stream will emit that failure.
Interleaves this stream and the specified stream deterministically by alternating pulling values from this stream and the specified stream. When one stream is exhausted all remaining values in the other stream will be pulled.
Interleaves this stream and the specified stream deterministically by alternating pulling values from this stream and the specified stream. When one stream is exhausted all remaining values in the other stream will be pulled.
Combines this stream and the specified stream deterministically using the
stream of boolean values b
to control which stream to pull from next.
true
indicates to pull from this stream and false
indicates to pull
from the specified stream. Only consumes as many elements as requested by
b
. If either this stream or the specified stream are exhausted further
requests for values from that stream will be ignored.
Combines this stream and the specified stream deterministically using the
stream of boolean values b
to control which stream to pull from next.
true
indicates to pull from this stream and false
indicates to pull
from the specified stream. Only consumes as many elements as requested by
b
. If either this stream or the specified stream are exhausted further
requests for values from that stream will be ignored.
Specialized version of interruptWhen which interrupts the evaluation of this stream after the given duration.
Specialized version of interruptWhen which interrupts the evaluation of this stream after the given duration.
Interrupts the evaluation of this stream when the provided IO completes. The given IO will be forked as part of this stream, and its success will be discarded. This combinator will also interrupt any in-progress element being pulled from upstream.
Interrupts the evaluation of this stream when the provided IO completes. The given IO will be forked as part of this stream, and its success will be discarded. This combinator will also interrupt any in-progress element being pulled from upstream.
If the IO completes with a failure before the stream completes, the returned stream will emit that failure.
Interrupts the evaluation of this stream when the provided promise resolves. This combinator will also interrupt any in-progress element being pulled from upstream.
Interrupts the evaluation of this stream when the provided promise resolves. This combinator will also interrupt any in-progress element being pulled from upstream.
If the promise completes with a failure, the stream will emit that failure.
Intersperse stream with provided element similar to
List.mkString
.
Intersperse stream with provided element similar to
List.mkString
.
Intersperse and also add a prefix and a suffix
Intersperse and also add a prefix and a suffix
Transforms the elements of this stream using the supplied function.
Transforms the elements of this stream using the supplied function.
Statefully maps over the elements of this stream to produce new elements.
Statefully maps over the elements of this stream to produce new elements.
Statefully and effectfully maps over the elements of this stream to produce new elements.
Statefully and effectfully maps over the elements of this stream to produce new elements.
Returns a stream whose failure and success channels have been mapped by the
specified pair of functions, f
and g
.
Returns a stream whose failure and success channels have been mapped by the
specified pair of functions, f
and g
.
Effectfully transforms the chunks emitted by this stream.
Effectfully transforms the chunks emitted by this stream.
Maps each element to an iterable, and flattens the iterables into the output of this stream.
Maps each element to an iterable, and flattens the iterables into the output of this stream.
Maps each element to a chunk, and flattens the chunks into the output of this stream.
Maps each element to a chunk, and flattens the chunks into the output of this stream.
Effectfully maps each element to a chunk, and flattens the chunks into the output of this stream.
Effectfully maps each element to a chunk, and flattens the chunks into the output of this stream.
Effectfully maps each element to an iterable, and flattens the iterables into the output of this stream.
Effectfully maps each element to an iterable, and flattens the iterables into the output of this stream.
Transforms the errors emitted by this stream using f
.
Transforms the errors emitted by this stream using f
.
Transforms the full causes of failures emitted by this stream.
Transforms the full causes of failures emitted by this stream.
Maps over elements of the stream with the specified effectful function.
Maps over elements of the stream with the specified effectful function.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently. Transformed elements
will be emitted in the original order.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently. Transformed elements
will be emitted in the original order.
- Note:
This combinator destroys the chunking structure. It's recommended to use rechunk afterwards.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently. The element order is
not enforced by this combinator, and elements may be reordered.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently. The element order is
not enforced by this combinator, and elements may be reordered.
Maps over elements of the stream with the specified effectful function,
partitioned by p
executing invocations of f
concurrently. The number of
concurrent invocations of f
is determined by the number of different
outputs of type K
. Up to buffer
elements may be buffered per partition.
Transformed elements may be reordered but the order within a partition is
maintained.
Maps over elements of the stream with the specified effectful function,
partitioned by p
executing invocations of f
concurrently. The number of
concurrent invocations of f
is determined by the number of different
outputs of type K
. Up to buffer
elements may be buffered per partition.
Transformed elements may be reordered but the order within a partition is
maintained.
Merges this stream and the specified stream together.
Merges this stream and the specified stream together.
New produced stream will terminate when both specified stream terminate if no termination strategy is specified.
Merges this stream and the specified stream together to produce a stream of eithers.
Merges this stream and the specified stream together to produce a stream of eithers.
Merges this stream and the specified stream together, discarding the values from the right stream.
Merges this stream and the specified stream together, discarding the values from the right stream.
Merges this stream and the specified stream together, discarding the values from the left stream.
Merges this stream and the specified stream together, discarding the values from the left stream.
Merges this stream and the specified stream together. New produced stream will terminate when either stream terminates.
Merges this stream and the specified stream together. New produced stream will terminate when either stream terminates.
Merges this stream and the specified stream together. New produced stream will terminate when this stream terminates.
Merges this stream and the specified stream together. New produced stream will terminate when this stream terminates.
Merges this stream and the specified stream together. New produced stream will terminate when the specified stream terminates.
Merges this stream and the specified stream together. New produced stream will terminate when the specified stream terminates.
Merges this stream and the specified stream together to a common element type with the specified mapping functions.
Merges this stream and the specified stream together to a common element type with the specified mapping functions.
New produced stream will terminate when both specified stream terminate if no termination strategy is specified.
Returns a combined string resulting from concatenating each of the values from the stream
Returns a combined string resulting from concatenating each of the values from the stream
Returns a combined string resulting from concatenating each of the values
from the stream beginning with before
interspersed with middle
and
ending with after
.
Returns a combined string resulting from concatenating each of the values
from the stream beginning with before
interspersed with middle
and
ending with after
.
Runs the specified effect if this stream fails, providing the error to the effect if it exists.
Runs the specified effect if this stream fails, providing the error to the effect if it exists.
Note: Unlike ZIO.onError, there is no guarantee that the provided effect will not be interrupted.
Locks the execution of this stream to the specified executor. Any streams that are composed after this one will automatically be shifted back to the previous executor.
Locks the execution of this stream to the specified executor. Any streams that are composed after this one will automatically be shifted back to the previous executor.
Switches to the provided stream in case this one fails with a typed error.
Switches to the provided stream in case this one fails with a typed error.
See also ZStream#catchAll.
Switches to the provided stream in case this one fails with a typed error.
Switches to the provided stream in case this one fails with a typed error.
See also ZStream#catchAll.
Fails with given error in case this one fails with a typed error.
Fails with given error in case this one fails with a typed error.
See also ZStream#catchAll.
Switches to the provided stream in case this one fails with the None
value.
Switches to the provided stream in case this one fails with the None
value.
See also ZStream#catchAll.
Succeeds with the specified value if this one fails with a typed error.
Succeeds with the specified value if this one fails with a typed error.
Partition a stream using a predicate. The first stream will contain all element evaluated to true and the second one will contain all element evaluated to false. The faster stream may advance by up to buffer elements further than the slower one.
Partition a stream using a predicate. The first stream will contain all element evaluated to true and the second one will contain all element evaluated to false. The faster stream may advance by up to buffer elements further than the slower one.
Split a stream by a predicate. The faster stream may advance by up to buffer elements further than the slower one.
Split a stream by a predicate. The faster stream may advance by up to buffer elements further than the slower one.
Pipes all of the values from this stream through the provided sink.
Pipes all of the values from this stream through the provided sink.
- See also:
Pipes all the values from this stream through the provided channel
Pipes all the values from this stream through the provided channel
Pipes all values from this stream through the provided channel, passing through any error emitted by this stream unchanged.
Pipes all values from this stream through the provided channel, passing through any error emitted by this stream unchanged.
Provides the stream with its required environment, which eliminates its
dependency on R
.
Provides the stream with its required environment, which eliminates its
dependency on R
.
Provides a layer to the stream, which translates it to another level.
Provides a layer to the stream, which translates it to another level.
Transforms the environment being provided to the stream with the specified function.
Transforms the environment being provided to the stream with the specified function.
Splits the environment into two parts, providing one part using the
specified layer and leaving the remainder R0
.
Splits the environment into two parts, providing one part using the
specified layer and leaving the remainder R0
.
val loggingLayer: ZLayer[Any, Nothing, Logging] = ???
val stream: ZStream[Logging with Database, Nothing, Unit] = ???
val stream2 = stream.provideSomeLayer[Database](loggingLayer)
Re-chunks the elements of the stream into chunks of n
elements each. The
last chunk might contain less than n
elements
Re-chunks the elements of the stream into chunks of n
elements each. The
last chunk might contain less than n
elements
Keeps some of the errors, and terminates the fiber with the rest
Keeps some of the errors, and terminates the fiber with the rest
Keeps some of the errors, and terminates the fiber with the rest, using the
specified function to convert the E
into a Throwable
.
Keeps some of the errors, and terminates the fiber with the rest, using the
specified function to convert the E
into a Throwable
.
Keeps some of the errors, and terminates the fiber with the rest.
Keeps some of the errors, and terminates the fiber with the rest.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule. The schedule output will be emitted at the end of each repetition.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule. The schedule output will be emitted at the end of each repetition.
Repeats each element of the stream using the provided schedule. Repetitions
are done in addition to the first execution, which means using
Schedule.recurs(1)
actually results in the original effect, plus an
additional recurrence, for a total of two repetitions of each value in the
stream.
Repeats each element of the stream using the provided schedule. Repetitions
are done in addition to the first execution, which means using
Schedule.recurs(1)
actually results in the original effect, plus an
additional recurrence, for a total of two repetitions of each value in the
stream.
Repeats each element of the stream using the provided schedule. When the
schedule is finished, then the output of the schedule will be emitted into
the stream. Repetitions are done in addition to the first execution, which
means using Schedule.recurs(1)
actually results in the original effect,
plus an additional recurrence, for a total of two repetitions of each value
in the stream.
Repeats each element of the stream using the provided schedule. When the
schedule is finished, then the output of the schedule will be emitted into
the stream. Repetitions are done in addition to the first execution, which
means using Schedule.recurs(1)
actually results in the original effect,
plus an additional recurrence, for a total of two repetitions of each value
in the stream.
Repeats each element of the stream using the provided schedule. When the
schedule is finished, then the output of the schedule will be emitted into
the stream. Repetitions are done in addition to the first execution, which
means using Schedule.recurs(1)
actually results in the original effect,
plus an additional recurrence, for a total of two repetitions of each value
in the stream.
Repeats each element of the stream using the provided schedule. When the
schedule is finished, then the output of the schedule will be emitted into
the stream. Repetitions are done in addition to the first execution, which
means using Schedule.recurs(1)
actually results in the original effect,
plus an additional recurrence, for a total of two repetitions of each value
in the stream.
This function accepts two conversion functions, which allow the output of
this stream and the output of the provided schedule to be unified into a
single type. For example, Either
or similar data type.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule. The schedule output will be emitted at the end of each repetition and can be unified with the stream elements using the provided functions.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule. The schedule output will be emitted at the end of each repetition and can be unified with the stream elements using the provided functions.
When the stream fails, retry it according to the given schedule
When the stream fails, retry it according to the given schedule
This retries the entire stream, so will re-execute all of the stream's acquire operations.
The schedule is reset as soon as the first element passes through the stream again.
- Value parameters:
- schedule
Schedule receiving as input the errors of the stream
- Returns:
Stream outputting elements of all attempts of the stream
Fails with given error 'e' if value is Left
.
Fails with given error 'e' if value is Left
.
Runs the sink on the stream to produce either the sink's result or an error.
Runs the sink on the stream to produce either the sink's result or an error.
Runs the stream and collects all of its elements to a chunk.
Runs the stream and collects all of its elements to a chunk.
Runs the stream and emits the number of elements processed
Runs the stream and emits the number of elements processed
Equivalent to run(ZSink.count)
Runs the stream only for its effects. The emitted elements are discarded.
Runs the stream only for its effects. The emitted elements are discarded.
Executes a pure fold over the stream of values - reduces all elements in
the stream to a value of type S
.
Executes a pure fold over the stream of values - reduces all elements in
the stream to a value of type S
.
Executes a pure fold over the stream of values. Returns a scoped value that represents the scope of the stream.
Executes a pure fold over the stream of values. Returns a scoped value that represents the scope of the stream.
Executes an effectful fold over the stream of values. Returns a scoped value that represents the scope of the stream.
Executes an effectful fold over the stream of values. Returns a scoped value that represents the scope of the stream.
Reduces the elements in the stream to a value of type S
. Stops the fold
early when the condition is not fulfilled. Example:
Reduces the elements in the stream to a value of type S
. Stops the fold
early when the condition is not fulfilled. Example:
Stream(1).forever.foldWhile(0)(_ <= 4)(_ + _) // UIO[Int] == 5
Executes a pure fold over the stream of values. Returns a scoped value that represents the scope of the stream. Stops the fold early when the condition is not fulfilled.
Executes a pure fold over the stream of values. Returns a scoped value that represents the scope of the stream. Stops the fold early when the condition is not fulfilled.
Executes an effectful fold over the stream of values. Returns a scoped value that represents the scope of the stream. Stops the fold early when the condition is not fulfilled. Example:
Executes an effectful fold over the stream of values. Returns a scoped value that represents the scope of the stream. Stops the fold early when the condition is not fulfilled. Example:
Stream(1)
.forever // an infinite Stream of 1's
.fold(0)(_ <= 4)((s, a) => ZIO.succeed(s + a)) // URIO[Scope, Int] == 5
- Value parameters:
- cont
function which defines the early termination condition
Executes an effectful fold over the stream of values. Stops the fold early when the condition is not fulfilled. Example:
Executes an effectful fold over the stream of values. Stops the fold early when the condition is not fulfilled. Example:
Stream(1)
.forever // an infinite Stream of 1's
.fold(0)(_ <= 4)((s, a) => ZIO.succeed(s + a)) // UIO[Int] == 5
- Value parameters:
- cont
function which defines the early termination condition
Executes an effectful fold over the stream of values.
Executes an effectful fold over the stream of values.
Consumes all elements of the stream, passing them to the specified callback.
Consumes all elements of the stream, passing them to the specified callback.
Consumes all elements of the stream, passing them to the specified callback.
Consumes all elements of the stream, passing them to the specified callback.
Like ZStream#runForeachChunk, but returns a scoped ZIO
so the
finalization order can be controlled.
Like ZStream#runForeachChunk, but returns a scoped ZIO
so the
finalization order can be controlled.
Like ZStream#foreach, but returns a scoped ZIO
so the finalization
order can be controlled.
Like ZStream#foreach, but returns a scoped ZIO
so the finalization
order can be controlled.
Consumes elements of the stream, passing them to the specified callback,
and terminating consumption when the callback returns false
.
Consumes elements of the stream, passing them to the specified callback,
and terminating consumption when the callback returns false
.
Like ZStream#runForeachWhile, but returns a scoped ZIO
so the
finalization order can be controlled.
Like ZStream#runForeachWhile, but returns a scoped ZIO
so the
finalization order can be controlled.
Runs the stream to completion and yields the first value emitted by it, discarding the rest of the elements.
Runs the stream to completion and yields the first value emitted by it, discarding the rest of the elements.
Publishes elements of this stream to a hub. Stream failure and ending will also be signalled.
Publishes elements of this stream to a hub. Stream failure and ending will also be signalled.
Like ZStream#runIntoHub, but provides the result as a scoped ZIO to allow for scope composition.
Like ZStream#runIntoHub, but provides the result as a scoped ZIO to allow for scope composition.
Enqueues elements of this stream into a queue. Stream failure and ending will also be signalled.
Enqueues elements of this stream into a queue. Stream failure and ending will also be signalled.
Like ZStream#runIntoQueue, but provides the result as a scoped ZIO to allow for scope composition.
Like ZStream#runIntoQueue, but provides the result as a scoped ZIO to allow for scope composition.
Like ZStream#runIntoQueue, but provides the result as a scoped [[ZIO] to allow for scope composition.
Like ZStream#runIntoQueue, but provides the result as a scoped [[ZIO] to allow for scope composition.
Runs the stream to completion and yields the last value emitted by it, discarding the rest of the elements.
Runs the stream to completion and yields the last value emitted by it, discarding the rest of the elements.
Runs the stream to a sink which sums elements, provided they are Numeric.
Runs the stream to a sink which sums elements, provided they are Numeric.
Equivalent to run(Sink.sum[A])
Statefully maps over the elements of this stream to produce all
intermediate results of type S
given an initial S.
Statefully maps over the elements of this stream to produce all
intermediate results of type S
given an initial S.
Statefully maps over the elements of this stream to produce all intermediate results.
Statefully maps over the elements of this stream to produce all intermediate results.
See also ZStream#scan.
Statefully and effectfully maps over the elements of this stream to produce all intermediate results.
Statefully and effectfully maps over the elements of this stream to produce all intermediate results.
See also ZStream#scanZIO.
Statefully and effectfully maps over the elements of this stream to produce
all intermediate results of type S
given an initial S.
Statefully and effectfully maps over the elements of this stream to produce
all intermediate results of type S
given an initial S.
Schedules the output of the stream using the provided schedule
.
Schedules the output of the stream using the provided schedule
.
Schedules the output of the stream using the provided schedule
and emits
its output at the end (if schedule
is finite).
Schedules the output of the stream using the provided schedule
and emits
its output at the end (if schedule
is finite).
Schedules the output of the stream using the provided schedule
and emits
its output at the end (if schedule
is finite). Uses the provided function
to align the stream and schedule outputs on the same type.
Schedules the output of the stream using the provided schedule
and emits
its output at the end (if schedule
is finite). Uses the provided function
to align the stream and schedule outputs on the same type.
Emits a sliding window of n elements.
Emits a sliding window of n elements.
Stream(1, 2, 3, 4).sliding(2).runCollect // Chunk(Chunk(1, 2), Chunk(2, 3), Chunk(3, 4))
Converts an option on values into an option on errors.
Converts an option on values into an option on errors.
Extracts the optional value, or returns the given 'default'.
Extracts the optional value, or returns the given 'default'.
Extracts the optional value, or fails with the given error 'e'.
Extracts the optional value, or fails with the given error 'e'.
Splits elements based on a predicate.
Splits elements based on a predicate.
ZStream.range(1, 10).split(_ % 4 == 0).runCollect // Chunk(Chunk(1, 2, 3), Chunk(5, 6, 7), Chunk(9))
Splits elements on a delimiter and transforms the splits into desired output.
Splits elements on a delimiter and transforms the splits into desired output.
Takes the specified number of elements from this stream.
Takes the specified number of elements from this stream.
Takes the last specified number of elements from this stream.
Takes the last specified number of elements from this stream.
Takes all elements of the stream until the specified predicate evaluates to
true
.
Takes all elements of the stream until the specified predicate evaluates to
true
.
Takes all elements of the stream until the specified effectual predicate
evaluates to true
.
Takes all elements of the stream until the specified effectual predicate
evaluates to true
.
Takes all elements of the stream for as long as the specified predicate
evaluates to true
.
Takes all elements of the stream for as long as the specified predicate
evaluates to true
.
Adds an effect to consumption of every element of the stream.
Adds an effect to consumption of every element of the stream.
Returns a stream that effectfully "peeks" at the failure of the stream.
Returns a stream that effectfully "peeks" at the failure of the stream.
Returns a stream that effectfully "peeks" at the cause of failure of the stream.
Returns a stream that effectfully "peeks" at the cause of failure of the stream.
Sends all elements emitted by this stream to the specified sink in addition to emitting them.
Sends all elements emitted by this stream to the specified sink in addition to emitting them.
Throttles the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. Chunks that do not meet the bandwidth
constraints are dropped. The weight of each chunk is determined by the
costFn
function.
Throttles the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. Chunks that do not meet the bandwidth
constraints are dropped. The weight of each chunk is determined by the
costFn
function.
Throttles the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. Chunks that do not meet the bandwidth
constraints are dropped. The weight of each chunk is determined by the
costFn
effectful function.
Throttles the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. Chunks that do not meet the bandwidth
constraints are dropped. The weight of each chunk is determined by the
costFn
effectful function.
Delays the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. The weight of each chunk is determined by
the costFn
function.
Delays the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. The weight of each chunk is determined by
the costFn
function.
Delays the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. The weight of each chunk is determined by
the costFn
effectful function.
Delays the chunks of this stream according to the given bandwidth
parameters using the token bucket algorithm. Allows for burst in the
processing of elements by allowing the token bucket to accumulate tokens up
to a units + burst
threshold. The weight of each chunk is determined by
the costFn
effectful function.
Ends the stream if it does not produce a value after d duration.
Ends the stream if it does not produce a value after d duration.
Fails the stream with given error if it does not produce a value after d duration.
Fails the stream with given error if it does not produce a value after d duration.
Fails the stream with given cause if it does not produce a value after d duration.
Fails the stream with given cause if it does not produce a value after d duration.
Switches the stream if it does not produce a value after d duration.
Switches the stream if it does not produce a value after d duration.
Converts the stream to a scoped hub of chunks. After the scope is closed, the hub will never again produce values and should be discarded.
Converts the stream to a scoped hub of chunks. After the scope is closed, the hub will never again produce values and should be discarded.
Converts the stream to a scoped queue of chunks. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a scoped queue of chunks. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a dropping scoped queue of chunks. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a dropping scoped queue of chunks. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a scoped queue of elements. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a scoped queue of elements. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a sliding scoped queue of chunks. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream to a sliding scoped queue of chunks. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream into an unbounded scoped queue. After the scope is closed, the queue will never again produce values and should be discarded.
Converts the stream into an unbounded scoped queue. After the scope is closed, the queue will never again produce values and should be discarded.
Applies the transducer to the stream and emits its outputs.
Applies the transducer to the stream and emits its outputs.
Updates a service in the environment of this effect.
Updates a service in the environment of this effect.
Updates a service at the specified key in the environment of this effect.
Updates a service at the specified key in the environment of this effect.
Threads the stream through a transformation pipeline.
Threads the stream through a transformation pipeline.
Threads the stream through the transformation function f
.
Threads the stream through the transformation function f
.
Returns this stream if the specified condition is satisfied, otherwise returns an empty stream.
Returns this stream if the specified condition is satisfied, otherwise returns an empty stream.
Returns this stream if the specified effectful condition is satisfied, otherwise returns an empty stream.
Returns this stream if the specified effectful condition is satisfied, otherwise returns an empty stream.
Zips this stream with another point-wise and emits tuples of elements from both streams.
Zips this stream with another point-wise and emits tuples of elements from both streams.
The new stream will end when one of the sides ends.
Zips this stream with another point-wise, creating a new stream of pairs of elements from both sides.
Zips this stream with another point-wise, creating a new stream of pairs of elements from both sides.
The defaults defaultLeft
and defaultRight
will be used if the streams
have different lengths and one of the streams has ended before the other.
Zips this stream with another point-wise, and keeps only elements from this stream.
Zips this stream with another point-wise, and keeps only elements from this stream.
The provided default value will be used if the other stream ends before this one.
Zips this stream with another point-wise, and keeps only elements from the other stream.
Zips this stream with another point-wise, and keeps only elements from the other stream.
The provided default value will be used if this stream ends before the other one.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Combines values associated with each key into a tuple,
using the specified values defaultLeft
and defaultRight
to fill in
missing values.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Combines values associated with each key into a tuple,
using the specified values defaultLeft
and defaultRight
to fill in
missing values.
This allows zipping potentially unbounded streams of data by key in constant space but the caller is responsible for ensuring that the streams are sorted by distinct keys.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Keeps only values from this stream, using the specified
value default
to fill in missing values.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Keeps only values from this stream, using the specified
value default
to fill in missing values.
This allows zipping potentially unbounded streams of data by key in constant space but the caller is responsible for ensuring that the streams are sorted by distinct keys.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Keeps only values from that stream, using the specified
value default
to fill in missing values.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Keeps only values from that stream, using the specified
value default
to fill in missing values.
This allows zipping potentially unbounded streams of data by key in constant space but the caller is responsible for ensuring that the streams are sorted by distinct keys.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Uses the functions left
, right
, and both
to handle
the cases where a key and value exist in this stream, that stream, or
both streams.
Zips this stream that is sorted by distinct keys and the specified stream
that is sorted by distinct keys to produce a new stream that is sorted by
distinct keys. Uses the functions left
, right
, and both
to handle
the cases where a key and value exist in this stream, that stream, or
both streams.
This allows zipping potentially unbounded streams of data by key in constant space but the caller is responsible for ensuring that the streams are sorted by distinct keys.
Zips this stream with another point-wise. The provided functions will be used to create elements for the composed stream.
Zips this stream with another point-wise. The provided functions will be used to create elements for the composed stream.
The functions left
and right
will be used if the streams have different
lengths and one of the streams has ended before the other.
Zips this stream with another point-wise, but keeps only the outputs of this stream.
Zips this stream with another point-wise, but keeps only the outputs of this stream.
The new stream will end when one of the sides ends.
Zips this stream with another point-wise, but keeps only the outputs of the other stream.
Zips this stream with another point-wise, but keeps only the outputs of the other stream.
The new stream will end when one of the sides ends.
Zips this stream with another point-wise and applies the function to the paired elements.
Zips this stream with another point-wise and applies the function to the paired elements.
The new stream will end when one of the sides ends.
Zips this stream with another point-wise and applies the function to the paired elements.
Zips this stream with another point-wise and applies the function to the paired elements.
The new stream will end when one of the sides ends.
Zips this stream together with the index of elements.
Zips this stream together with the index of elements.
Zips the two streams so that when a value is emitted by either of the two streams, it is combined with the latest value from the other stream to produce a result.
Zips the two streams so that when a value is emitted by either of the two streams, it is combined with the latest value from the other stream to produce a result.
Note: tracking the latest value is done on a per-chunk basis. That means that emitted elements that are not the last value in chunks will never be used for zipping.
Zips each element with the next element if present.
Zips each element with the next element if present.
Zips each element with the previous element. Initially accompanied by
None
.
Zips each element with the previous element. Initially accompanied by
None
.