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:
type ZPipeline[Env, Err, In, Out] = ZStream[Env, Err, In] => ZStream[Env, Err, Out]
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.
Attributes
- Companion:
- object
- Graph
- Supertypes
- Self type
Members list
Value members
Concrete methods
Composes two pipelines into one pipeline, by first applying the transformation of the specified pipeline, and then applying the transformation of this pipeline.
Composes two pipelines into one pipeline, by first applying the transformation of the specified pipeline, and then applying the transformation of this pipeline.
Attributes
Composes two pipelines into one pipeline, by first applying the transformation of this pipeline, and then applying the transformation of the specified pipeline.
Composes two pipelines into one pipeline, by first applying the transformation of this pipeline, and then applying the transformation of the specified pipeline.
Attributes
Compose this pipeline with a sink, resulting in a sink that processes elements by piping them through this pipeline and piping the results into the sink.
Compose this pipeline with a sink, resulting in a sink that processes elements by piping them through this pipeline and piping the results into the sink.
Attributes
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.
Attributes
Like aggregateAsyncWithinEither
, but only returns the Right
results.
Like aggregateAsyncWithinEither
, but only returns the Right
results.
Attributes
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.
Attributes
A named version of the >>>
operator.
A named version of the >>>
operator.
Attributes
Attach this pipeline to the given stream
Attach this pipeline to the given stream
Attributes
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 natural equality to determine whether two elements are equal.
Attributes
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 function to determine whether two elements are equal.
Attributes
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.
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.
Attributes
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.
Attributes
Performs a filter and map in a single step.
Performs a filter and map in a single step.
Attributes
Filters any Right
values.
Filters any Right
values.
Attributes
Filters any Left
values.
Filters any Left
values.
Attributes
Filters any 'None' values.
Filters any 'None' values.
Attributes
Filters any Exit.Failure
values.
Filters any Exit.Failure
values.
Attributes
Transforms all elements of the pipeline for as long as the specified partial function is defined.
Transforms all elements of the pipeline for as long as the specified partial function is defined.
Attributes
Terminates the pipeline when encountering the first Right
.
Terminates the pipeline when encountering the first Right
.
Attributes
Terminates the pipeline when encountering the first Left
.
Terminates the pipeline when encountering the first Left
.
Attributes
Terminates the pipeline when encountering the first None
.
Terminates the pipeline when encountering the first None
.
Attributes
Terminates the pipeline when encountering the first Exit.Failure
.
Terminates the pipeline when encountering the first Exit.Failure
.
Attributes
Effectfully transforms all elements of the pipeline for as long as the specified partial function is defined.
Effectfully transforms all elements of the pipeline for as long as the specified partial function is defined.
Attributes
A named version of the <<<
operator.
A named version of the <<<
operator.
Attributes
Converts this pipeline to a pipeline that executes its effects but emits no elements. Useful for sequencing effects using pipeline:
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)
Attributes
Drops the specified number of elements from this stream.
Drops the specified number of elements from this stream.
Attributes
Drops the last specified number of elements from this pipeline.
Drops the last specified number of elements from this pipeline.
Attributes
- Note:
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 all elements of the pipeline until the specified predicate evaluates
to true
.
Attributes
Drops incoming elements until the effectful predicate p
is satisfied.
Drops incoming elements until the effectful predicate p
is satisfied.
Attributes
Drops all elements of the pipeline for as long as the specified predicate
evaluates to true
.
Drops all elements of the pipeline for as long as the specified predicate
evaluates to true
.
Attributes
Drops incoming elements as long as the effectful predicate p
is
satisfied.
Drops incoming elements as long as the effectful predicate p
is
satisfied.
Attributes
Filters the elements emitted by this pipeline using the provided function.
Filters the elements emitted by this pipeline using the provided function.
Attributes
Effectfully filters the elements emitted by this pipeline.
Effectfully filters the elements emitted by this pipeline.
Attributes
Submerges the chunks carried by this pipeline into the pipeline's structure, while still preserving them.
Submerges the chunks carried by this pipeline into the pipeline's structure, while still preserving them.
Attributes
Submerges the iterables carried by this pipeline into the pipeline's structure, while still preserving them.
Submerges the iterables carried by this pipeline into the pipeline's structure, while still preserving them.
Attributes
Flattens take values.
Flattens take values.
Attributes
Partitions the pipeline with specified chunkSize
Partitions the pipeline with specified chunkSize
Attributes
- 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.
Attributes
Intersperse pipeline with provided element similar to
List.mkString
.
Intersperse pipeline with provided element similar to
List.mkString
.
Attributes
Intersperse and also add a prefix and a suffix
Intersperse and also add a prefix and a suffix
Attributes
Transforms the elements of this pipeline using the supplied function.
Transforms the elements of this pipeline using the supplied function.
Attributes
Statefully maps over the elements of this pipeline to produce new elements.
Statefully maps over the elements of this pipeline to produce new elements.
Attributes
Statefully and effectfully 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.
Attributes
Transforms the chunks emitted by this stream.
Transforms the chunks emitted by this stream.
Attributes
Creates a pipeline that maps chunks of elements with the specified effect.
Creates a pipeline that maps chunks of elements with the specified effect.
Attributes
Transforms the errors emitted by this pipeline using f
.
Transforms the errors emitted by this pipeline using f
.
Attributes
Creates a pipeline that maps elements with the specified function that returns a stream.
Creates a pipeline that maps elements with the specified function that returns a stream.
Attributes
Creates a pipeline that maps elements with the specified effectful function.
Creates a pipeline that maps elements with the specified effectful function.
Attributes
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.
Attributes
- 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.
Attributes
Translates pipeline failure into death of the fiber, making all failures unchecked and not a part of the type of the effect.
Translates pipeline failure into death of the fiber, making all failures unchecked and not a part of the type of the effect.
Attributes
Keeps none of the errors, and terminates the fiber with them, using the
specified function to convert the E
into a Throwable
.
Keeps none of the errors, and terminates the fiber with them, using the
specified function to convert the E
into a Throwable
.
Attributes
Takes the specified number of elements from this pipeline.
Takes the specified number of elements from this pipeline.
Attributes
Takes all elements of the pipeline until the specified predicate evaluates
to true
.
Takes all elements of the pipeline until the specified predicate evaluates
to true
.
Attributes
Takes all elements of the pipeline for as long as the specified predicate
evaluates to true
.
Takes all elements of the pipeline for as long as the specified predicate
evaluates to true
.
Attributes
Adds an effect to consumption of every element of the pipeline.
Adds an effect to consumption of every element of the pipeline.
Attributes
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. 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.
Attributes
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.
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.
Attributes
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. 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.
Attributes
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.
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.
Attributes
Converts this pipeline to its underlying channel
Converts this pipeline to its underlying channel
Attributes
Zips this pipeline together with the index of elements.
Zips this pipeline together with the index of elements.