Class/Object

zio.stream

ZPipeline

Related Docs: object ZPipeline | package stream

Permalink

final class ZPipeline[-Env, +Err, -In, +Out] extends AnyRef

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.

Self Type
ZPipeline[Env, Err, In, Out]
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ZPipeline
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def <<<[Env1 <: Env, Err1 >: Err, In2](that: ⇒ ZPipeline[Env1, Err1, In2, In])(implicit trace: Trace): ZPipeline[Env1, Err1, In2, Out]

    Permalink

    Composes two pipelines into one pipeline, by first applying the transformation of the specified pipeline, and then applying the transformation of this pipeline.

  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. def >>>[Env1 <: Env, Err1 >: Err, Leftover, Out2](that: ⇒ ZSink[Env1, Err1, Out, Leftover, Out2])(implicit trace: Trace): ZSink[Env1, Err1, In, Leftover, Out2]

    Permalink

    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.

  6. def >>>[Env1 <: Env, Err1 >: Err, Out2](that: ⇒ ZPipeline[Env1, Err1, Out, Out2])(implicit trace: Trace): ZPipeline[Env1, Err1, In, Out2]

    Permalink

    Composes two pipelines into one pipeline, by first applying the transformation of this pipeline, and then applying the transformation of the specified pipeline.

  7. def andThen[Env1 <: Env, Err1 >: Err, Out2](that: ⇒ ZPipeline[Env1, Err1, Out, Out2])(implicit trace: Trace): ZPipeline[Env1, Err1, In, Out2]

    Permalink

    A named version of the >>> operator.

  8. def apply[Env1 <: Env, Err1 >: Err](stream: ⇒ ZStream[Env1, Err1, In])(implicit trace: Trace): ZStream[Env1, Err1, Out]

    Permalink

    Attach this pipeline to the given stream

  9. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  10. def changes(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    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.

  11. def changesWith(f: (Out, Out) ⇒ Boolean)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    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.

  12. def changesWithZIO(f: (Out, Out) ⇒ UIO[Boolean])(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    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.

  13. val channel: ZChannel[Env, ZNothing, Chunk[In], Any, Err, Chunk[Out], Any]

    Permalink
  14. def chunks(implicit trace: Trace): ZPipeline[Env, Err, In, Chunk[Out]]

    Permalink

    Exposes the underlying chunks of the stream as a stream of chunks of elements.

  15. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  16. def collect[Out2](pf: PartialFunction[Out, Out2])(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Performs a filter and map in a single step.

  17. def collectLeft[A, B](implicit ev: <:<[Out, Either[A, B]], trace: Trace): ZPipeline[Env, Err, In, A]

    Permalink

    Filters any Right values.

  18. def collectRight[A, B](implicit ev: <:<[Out, Either[A, B]], trace: Trace): ZPipeline[Env, Err, In, B]

    Permalink

    Filters any Left values.

  19. def collectSome[Out2](implicit ev: <:<[Out, Option[Out2]], trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Filters any 'None' values.

  20. def collectSuccess[Out2, L1](implicit ev: <:<[Out, Exit[L1, Out2]], trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Filters any Exit.Failure values.

  21. def collectWhile[Out2](pf: PartialFunction[Out, Out2])(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Transforms all elements of the pipeline for as long as the specified partial function is defined.

  22. def collectWhileLeft[A, B](implicit ev: <:<[Out, Either[A, B]], trace: Trace): ZPipeline[Env, Err, In, A]

    Permalink

    Terminates the pipeline when encountering the first Right.

  23. def collectWhileRight[A, B](implicit ev: <:<[Out, Either[A, B]], trace: Trace): ZPipeline[Env, Err, In, B]

    Permalink

    Terminates the pipeline when encountering the first Left.

  24. def collectWhileSome[Out2](implicit ev: <:<[Out, Option[Out2]], trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Terminates the pipeline when encountering the first None.

  25. def collectWhileSuccess[Err2, Out2](implicit ev: <:<[Out, Exit[Err2, Out2]], trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Terminates the pipeline when encountering the first Exit.Failure.

  26. def collectWhileZIO[Env2 <: Env, Err2 >: Err, Out2](pf: PartialFunction[Out, ZIO[Env2, Err2, Out2]])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out2]

    Permalink

    Effectfully transforms all elements of the pipeline for as long as the specified partial function is defined.

  27. def compose[Env1 <: Env, Err1 >: Err, In2](that: ⇒ ZPipeline[Env1, Err1, In2, In])(implicit trace: Trace): ZPipeline[Env1, Err1, In2, Out]

    Permalink

    A named version of the <<< operator.

  28. def drain(implicit trace: Trace): ZPipeline[Env, Err, In, Nothing]

    Permalink

    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)
  29. def drop(n: ⇒ Int)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Drops the specified number of elements from this stream.

  30. def dropRight(n: ⇒ Int)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Drops the last specified number of elements from this pipeline.

    Drops the last specified number of elements from this pipeline.

    Note

    This combinator keeps n elements in memory. Be careful with big numbers.

  31. def dropUntil(f: (Out) ⇒ Boolean)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Drops all elements of the pipeline until the specified predicate evaluates to true.

  32. def dropUntilZIO[Env1 <: Env, Err1 >: Err](f: (Out) ⇒ ZIO[Env1, Err1, Boolean])(implicit trace: Trace): ZPipeline[Env1, Err1, In, Out]

    Permalink

    Drops incoming elements until the effectful predicate p is satisfied.

  33. def dropWhile(f: (Out) ⇒ Boolean)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Drops all elements of the pipeline for as long as the specified predicate evaluates to true.

  34. def dropWhileZIO[Env1 <: Env, Err1 >: Err](f: (Out) ⇒ ZIO[Env1, Err1, Boolean])(implicit trace: Trace): ZPipeline[Env1, Err1, In, Out]

    Permalink

    Drops incoming elements as long as the effectful predicate p is satisfied.

  35. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  36. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  37. def filter(f: (Out) ⇒ Boolean)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Filters the elements emitted by this pipeline using the provided function.

  38. def filterZIO[Env2 <: Env, Err2 >: Err](f: (Out) ⇒ ZIO[Env2, Err2, Boolean])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out]

    Permalink

    Effectfully filters the elements emitted by this pipeline.

  39. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  40. def flattenChunks[Out2](implicit ev: <:<[Out, Chunk[Out2]], trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Submerges the chunks carried by this pipeline into the pipeline's structure, while still preserving them.

  41. def flattenExit[Err2, Out2](implicit ev: <:<[Out, Exit[Err2, Out2]], trace: Trace): ZPipeline[Env, Err2, In, Out2]

    Permalink

    Flattens Exit values.

    Flattens Exit values. Exit.Failure values translate to pipeline failures while Exit.Success values translate to stream elements.

  42. def flattenIterables[Out2](implicit ev: <:<[Out, Iterable[Out2]], trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Submerges the iterables carried by this pipeline into the pipeline's structure, while still preserving them.

  43. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  44. def grouped(chunkSize: ⇒ Int)(implicit trace: Trace): ZPipeline[Env, Err, In, Chunk[Out]]

    Permalink

    Partitions the pipeline with specified chunkSize

    Partitions the pipeline with specified chunkSize

    chunkSize

    size of the chunk

  45. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  46. def intersperse[Out2 >: Out](start: ⇒ Out2, middle: ⇒ Out2, end: ⇒ Out2)(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Intersperse and also add a prefix and a suffix

  47. def intersperse[Out2 >: Out](middle: ⇒ Out2)(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Intersperse pipeline with provided element similar to List.mkString.

    Intersperse pipeline with provided element similar to List.mkString.

  48. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  49. def map[Out2](f: (Out) ⇒ Out2)(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Transforms the elements of this pipeline using the supplied function.

  50. def mapAccum[State, Out2](s: ⇒ State)(f: (State, Out) ⇒ (State, Out2))(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Statefully maps over the elements of this pipeline to produce new elements.

  51. def mapAccumZIO[Env2 <: Env, Err2 >: Err, State, Out2](s: ⇒ State)(f: (State, Out) ⇒ ZIO[Env2, Err2, (State, Out2)])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out2]

    Permalink

    Statefully and effectfully maps over the elements of this pipeline to produce new elements.

  52. def mapChunks[Out2](f: (Chunk[Out]) ⇒ Chunk[Out2])(implicit trace: Trace): ZPipeline[Env, Err, In, Out2]

    Permalink

    Transforms the chunks emitted by this stream.

  53. def mapChunksZIO[Env2 <: Env, Err2 >: Err, Out2](f: (Chunk[Out]) ⇒ ZIO[Env2, Err2, Chunk[Out2]])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out2]

    Permalink

    Creates a pipeline that maps chunks of elements with the specified effect.

  54. def mapError[Err2](f: (Err) ⇒ Err2)(implicit trace: Trace): ZPipeline[Env, Err2, In, Out]

    Permalink

    Transforms the errors emitted by this pipeline using f.

  55. def mapErrorCause[Err2](f: (Cause[Err]) ⇒ Cause[Err2])(implicit trace: Trace): ZPipeline[Env, Err2, In, Out]

    Permalink

    A more powerful version of mapError which also surfaces the Cause of the channel failure

  56. def mapStream[Env2 <: Env, Err2 >: Err, Out2](f: (Out) ⇒ ZStream[Env2, Err2, Out2])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out2]

    Permalink

    Creates a pipeline that maps elements with the specified function that returns a stream.

  57. def mapZIO[Env2 <: Env, Err2 >: Err, Out2](f: (Out) ⇒ ZIO[Env2, Err2, Out2])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out2]

    Permalink

    Creates a pipeline that maps elements with the specified effectful function.

  58. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  59. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  60. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  61. def orDie(implicit ev: <:<[Err, Throwable], trace: Trace): ZPipeline[Env, Nothing, In, Out]

    Permalink

    Translates pipeline failure into death of the fiber, making all failures unchecked and not a part of the type of the effect.

  62. def orDieWith(f: (Err) ⇒ Throwable)(implicit trace: Trace): ZPipeline[Env, Nothing, In, Out]

    Permalink

    Keeps none of the errors, and terminates the fiber with them, using the specified function to convert the E into a Throwable.

  63. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  64. def take(n: ⇒ Long)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Takes the specified number of elements from this pipeline.

  65. def takeUntil(f: (Out) ⇒ Boolean)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Takes all elements of the pipeline until the specified predicate evaluates to true.

  66. def takeWhile(f: (Out) ⇒ Boolean)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    Takes all elements of the pipeline for as long as the specified predicate evaluates to true.

  67. def tap[Env2 <: Env, Err2 >: Err](f: (Out) ⇒ ZIO[Env2, Err2, Any])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out]

    Permalink

    Adds an effect to consumption of every element of the pipeline.

  68. def throttleEnforce(units: Long, duration: ⇒ zio.Duration, burst: ⇒ Long = 0)(costFn: (Chunk[Out]) ⇒ Long)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    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.

  69. def throttleEnforceZIO[Env2 <: Env, Err2 >: Err](units: ⇒ Long, duration: ⇒ zio.Duration, burst: ⇒ Long = 0)(costFn: (Chunk[Out]) ⇒ ZIO[Env2, Err2, Long])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out]

    Permalink

    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.

  70. def throttleShape(units: ⇒ Long, duration: ⇒ zio.Duration, burst: Long = 0)(costFn: (Chunk[Out]) ⇒ Long)(implicit trace: Trace): ZPipeline[Env, Err, In, Out]

    Permalink

    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.

  71. def throttleShapeZIO[Env2 <: Env, Err2 >: Err](units: ⇒ Long, duration: ⇒ zio.Duration, burst: ⇒ Long = 0)(costFn: (Chunk[Out]) ⇒ ZIO[Env2, Err2, Long])(implicit trace: Trace): ZPipeline[Env2, Err2, In, Out]

    Permalink

    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.

  72. def toChannel: ZChannel[Env, ZNothing, Chunk[In], Any, Err, Chunk[Out], Any]

    Permalink

    Converts this pipeline to its underlying channel

  73. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  74. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  75. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  76. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  77. def zipWithIndex(implicit trace: Trace): ZPipeline[Env, Err, In, (Out, Long)]

    Permalink

    Zips this pipeline together with the index of elements.

  78. def zipWithNext(implicit trace: Trace): ZPipeline[Env, Err, In, (Out, Option[Out])]

    Permalink
  79. def zipWithPrevious(implicit trace: Trace): ZPipeline[Env, Err, In, (Option[Out], Out)]

    Permalink
  80. def zipWithPreviousAndNext(implicit trace: Trace): ZPipeline[Env, Err, In, (Option[Out], Out, Option[Out])]

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped