Composes two pipelines into one pipeline, by first applying the transformation of the specified pipeline, and then applying the transformation of this pipeline.
Compose this transducer with a sink, resulting in a sink that processes elements by piping them through this transducer and piping the results into the sink.
Composes two pipelines into one pipeline, by first applying the transformation of this pipeline, and then applying the transformation of the specified pipeline.
A named version of the >>>
operator.
Attach this pipeline to the given stream
Returns a new pipeline 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 pipeline 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 pipeline 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.
Performs a filter and map in a single step.
Filters any Right
values.
Filters any Left
values.
Filters any 'None' values.
Filters any Exit.Failure
values.
Transforms all elements of the pipeline for as long as the specified partial function is defined.
Terminates the pipeline when encountering the first Right
.
Terminates the pipeline when encountering the first Left
.
Terminates the pipeline when encountering the first None
.
Terminates the pipeline when encountering the first Exit.Failure
.
Effectfully transforms all elements of the pipeline for as long as the specified partial function is defined.
A named version of the <<<
operator.
Converts this pipeline to a pipeline that executes its effects but emits no elements.
Converts this pipeline to a pipeline that executes its effects but emits no elements. Useful for sequencing effects using pipeline:
(Stream(1, 2, 3).tap(i => ZIO(println(i))) ++ (Stream.fromZIO(ZIO(println("Done!"))) >>> ZPipeline.drain) ++ Stream(4, 5, 6).tap(i => ZIO(println(i)))).run(Sink.drain)
Drops the specified number of elements from this stream.
Drops the last specified number of elements from this pipeline.
Drops the last specified number of elements from this pipeline.
This combinator keeps n
elements in memory. Be careful with big
numbers.
Drops all elements of the pipeline until the specified predicate evaluates
to true
.
Drops incoming elements until the effectful predicate p
is satisfied.
Drops all elements of the pipeline for as long as the specified predicate
evaluates to true
.
Drops incoming elements as long as the effectful predicate p
is
satisfied.
Filters the elements emitted by this pipeline using the provided function.
Effectfully filters the elements emitted by this pipeline.
Submerges the chunks carried by this pipeline into the pipeline's structure, while still preserving them.
Flattens Exit values.
Flattens Exit values. Exit.Failure
values translate to pipeline
failures while Exit.Success
values translate to stream elements.
Submerges the iterables carried by this pipeline into the pipeline's structure, while still preserving them.
Partitions the pipeline with specified chunkSize
Partitions the pipeline with specified chunkSize
size of the chunk
Intersperse and also add a prefix and a suffix
Intersperse pipeline with provided element similar to
List.mkString
.
Intersperse pipeline with provided element similar to
List.mkString
.
Transforms the elements of this pipeline using the supplied function.
Statefully maps over the elements of this pipeline to produce new elements.
Statefully and effectfully maps over the elements of this pipeline to produce new elements.
Transforms the chunks emitted by this stream.
Creates a pipeline that maps chunks of elements with the specified effect.
Transforms the errors emitted by this pipeline using f
.
A more powerful version of mapError which also surfaces the Cause of the channel failure
Creates a pipeline that maps elements with the specified function that returns a stream.
Creates a pipeline that maps elements with the specified effectful function.
Translates pipeline failure into death of the fiber, making all failures unchecked and not a part of the type of the effect.
Keeps none of the errors, and terminates the fiber with them, using the
specified function to convert the E
into a Throwable
.
Takes the specified number of elements from this pipeline.
Takes all elements of the pipeline until the specified predicate evaluates
to true
.
Takes all elements of the pipeline for as long as the specified predicate
evaluates to true
.
Adds an effect to consumption of every element of the pipeline.
Throttles the chunks of this pipeline according to the given bandwidth parameters using the token bucket algorithm.
Throttles the chunks of this pipeline 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 pipeline according to the given bandwidth parameters using the token bucket algorithm.
Throttles the chunks of this pipeline 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 pipeline according to the given bandwidth parameters using the token bucket algorithm.
Delays the chunks of this pipeline 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 pipeline according to the given bandwidth parameters using the token bucket algorithm.
Delays the chunks of this pipeline 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.
Converts this pipeline to its underlying channel
Zips this pipeline together with the index of elements.
A
ZPipeline[Env, Err, In, Out]
is a polymorphic stream transformer. Pipelines accept a stream as input, and return the transformed stream as output.Pipelines can be thought of as a recipe for calling a bunch of methods on a source stream, to yield a new (transformed) stream. A nice mental model is the following type alias:
This encoding of a pipeline with a type alias is not used because it does not infer well. In its place, this trait captures the polymorphism inherent to many pipelines, which can therefore be more flexible about the environment and error types of the streams they transform.
There is no fundamental requirement for pipelines to exist, because everything pipelines do can be done directly on a stream. However, because pipelines separate the stream transformation from the source stream itself, it becomes possible to abstract over stream transformations at the level of values, creating, storing, and passing around reusable transformation pipelines that can be applied to many different streams.
The most common way to create a pipeline is to convert a sink into a pipeline (in general, transforming elements of a stream requires the power of a sink). However, the companion object has lots of other pipeline constructors based on the methods of stream.