Packages

abstract class ZStream[-R, +E, +O] extends AnyRef

A ZStream[R, E, O] is a description of a program that, when evaluated, may emit 0 or more values of type O, may fail with errors of type E and uses an environment of type R. One way to think of ZStream is as a ZIO program that could emit multiple values.

Another analogue to ZStream is an imperative iterator:

trait Iterator[A] {
  def next: A
}

This data type can emit multiple A values through multiple calls to next. Similarly, embedded inside every ZStream is a ZIO program: ZIO[R, Option[E], Chunk[O]]. This program will be repeatedly evaluated as part of the stream execution. For every evaluation, it will emit a chunk of values or end with an optional failure. A failure of type None signals the end of the stream.

ZStream is a purely functional *pull* based stream. Pull based streams offer inherent laziness and backpressure, relieving users of the need to manage buffers between operators. As an optimization, ZStream does not emit single values, but rather zio.Chunk values. This allows the cost of effect evaluation to be amortized and most importantly, keeps primitives unboxed. This allows ZStream to model network and file-based stream processing extremely efficiently.

The last important attribute of ZStream is resource management: it makes heavy use of ZManaged to manage resources that are acquired and released during the stream's lifetime.

ZStream forms a monad on its O type parameter, and has error management facilities for its E type parameter, modeled similarly to ZIO (with some adjustments for the multiple-valued nature of ZStream). These aspects allow for rich and expressive composition of streams.

The current encoding of ZStream is *not* safe for recursion. ZStream programs that are defined in terms of themselves will leak memory. For example, the following implementation of ZStream#forever is not heap-safe:

def forever = self ++ forever

Instead, recursive operators must be defined explicitly. See the definition of ZStream#forever for an example. This limitation will be lifted in the future.

Self Type
ZStream[R, E, O]
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ZStream
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ZStream(process: ZManaged[R, Nothing, ZIO[R, Option[E], Chunk[O]]])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def &>[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    Symbolic alias for ZStream#zipRight.

  4. final def *>[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    Symbolic alias for ZStream#crossRight.

  5. def ++[R1 <: R, E1 >: E, O1 >: O](that: => ZStream[R1, E1, O1]): ZStream[R1, E1, O1]

    Symbolic alias for ZStream#concat.

  6. final def <&[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O]

    Symbolic alias for ZStream#zipLeft.

  7. final def <&>[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, (O, O2)]

    Symbolic alias for ZStream#zip.

  8. final def <*[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O]

    Symbolic alias for ZStream#crossLeft.

  9. final def <*>[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, (O, O2)]

    Symbolic alias for ZStream#cross.

  10. final def <>[R1 <: R, E2, O1 >: O](that: => ZStream[R1, E2, O1])(implicit ev: CanFail[E]): ZStream[R1, E2, O1]

    Symbolic alias for ZStream#orElse.

  11. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  12. def >>=[R1 <: R, E1 >: E, O2](f0: (O) => ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    Symbolic alias for ZStream#flatMap.

  13. def >>>[R1 <: R, E1 >: E, O2 >: O, Z](sink: ZSink[R1, E1, O2, Any, Z]): ZIO[R1, E1, Z]

    Symbolic alias for zio.stream.ZStream!.run[R1<:R,E1>:E,B]*.

  14. def >>>[R1 <: R, E1 >: E, O2 >: O, O3](transducer: ZTransducer[R1, E1, O2, O3]): ZStream[R1, E1, O3]

    Symbolic alias for ZStream#transduce.

  15. final def absolve[R1 <: R, E1, O1](implicit ev: <:<[ZStream[R, E, O], ZStream[R1, E1, Either[E1, O1]]]): ZStream[R1, E1, O1]

    Returns a stream that submerges the error case of an Either into the ZStream.

  16. def aggregate[R1 <: R, E1 >: E, P](transducer: ZTransducer[R1, E1, O, P]): ZStream[R1, E1, P]

    Applies an aggregator to the stream, which converts one or more elements of type A into elements of type B.

  17. final def aggregateAsync[R1 <: R, E1 >: E, P](transducer: ZTransducer[R1, E1, O, P]): ZStream[R1 with Clock, E1, P]

    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 transducer can be used here, but see ZTransducer.foldWeightedM and ZTransducer.foldUntilM for transducers that cover the common usecases.

  18. final def aggregateAsyncWithin[R1 <: R, E1 >: E, P](transducer: ZTransducer[R1, E1, O, P], schedule: Schedule[R1, Chunk[P], Any]): ZStream[R1 with Clock, E1, P]

    Uses aggregateAsyncWithinEither but only returns the Right results.

    Uses aggregateAsyncWithinEither but only returns the Right results.

    R1

    environment type

    E1

    error type

    P

    type of the value produced by the given transducer and consumed by the given schedule

    transducer

    used for the aggregation

    schedule

    signalling for when to stop the aggregation

    returns

    ZStream[R1, E1, P]

  19. final def aggregateAsyncWithinEither[R1 <: R, E1 >: E, P, Q](transducer: ZTransducer[R1, E1, O, P], schedule: Schedule[R1, Chunk[P], Q]): ZStream[R1 with Clock, E1, Either[Q, P]]

    Aggregates elements using the provided transducer until it signals completion, or the delay signalled by the schedule has passed.

    Aggregates elements using the provided transducer until it signals completion, or 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 transducer 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.

    R1

    environment type

    E1

    error type

    P

    type of the value produced by the given transducer and consumed by the given schedule

    Q

    type of the value produced by the given schedule

    transducer

    used for the aggregation

    schedule

    signalling for when to stop the aggregation

    returns

    ZStream[R1, E1, Either[Q, P]]

  20. def as[O2](o2: => O2): ZStream[R, E, O2]

    Maps the success values of this stream to the specified constant value.

  21. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  22. final def broadcast(n: Int, maximumLag: Int): ZManaged[R, Nothing, List[ZStream[Any, E, O]]]

    Fan out the stream, producing a list of streams that have the same elements as this 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.

  23. final def broadcastDynamic(maximumLag: Int): ZManaged[R, Nothing, ZStream[Any, E, O]]

    Fan out the stream, producing a dynamic number of streams that have the same elements as this 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.

  24. final def broadcastedQueues(n: Int, maximumLag: Int): ZManaged[R, Nothing, List[Dequeue[Take[E, O]]]]

    Converts the stream to a managed list of queues.

    Converts the stream to a managed 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.

  25. final def broadcastedQueuesDynamic(maximumLag: Int): ZManaged[R, Nothing, ZManaged[Any, Nothing, Dequeue[Take[E, O]]]]

    Converts the stream to a managed dynamic amount of queues.

    Converts the stream to a managed 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.

  26. final def buffer(capacity: Int): ZStream[R, E, O]

    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.

  27. final def bufferDropping(capacity: Int): ZStream[R, E, O]

    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

    Prefer capacities that are powers of 2 for better performance.

  28. final def bufferSliding(capacity: Int): ZStream[R, E, O]

    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

    Prefer capacities that are powers of 2 for better performance.

  29. final def bufferUnbounded: ZStream[R, E, O]

    Allows a faster producer to progress independently of a slower consumer by buffering elements into an unbounded queue.

  30. final def catchAll[R1 <: R, E2, O1 >: O](f: (E) => ZStream[R1, E2, O1])(implicit ev: CanFail[E]): ZStream[R1, E2, O1]

    Switches over to the stream produced by the provided function in case this one fails with a typed error.

  31. final def catchAllCause[R1 <: R, E2, O1 >: O](f: (Cause[E]) => ZStream[R1, E2, O1]): ZStream[R1, E2, O1]

    Switches over to the stream produced by the provided function in case this one fails.

    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.

  32. final def catchSome[R1 <: R, E1 >: E, O1 >: O](pf: PartialFunction[E, ZStream[R1, E1, O1]]): ZStream[R1, E1, O1]

    Switches over to the stream produced by the provided function in case this one fails with some typed error.

  33. final def catchSomeCause[R1 <: R, E1 >: E, O1 >: O](pf: PartialFunction[Cause[E], ZStream[R1, E1, O1]]): ZStream[R1, E1, O1]

    Switches over to the stream produced by the provided function in case this one fails with some errors.

    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.

  34. def changes: ZStream[R, E, O]

    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.

  35. def changesWith(f: (O, O) => Boolean): ZStream[R, E, O]

    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.

  36. def chunkN(n: Int): ZStream[R, E, O]

    Re-chunks the elements of the stream into chunks of n elements each.

    Re-chunks the elements of the stream into chunks of n elements each. The last chunk might contain less than n elements

  37. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  38. def collect[O1](pf: PartialFunction[O, O1]): ZStream[R, E, O1]

    Performs a filter and map in a single step.

  39. final def collectLeft[L1, O1](implicit ev: <:<[O, Either[L1, O1]]): ZStream[R, E, L1]

    Filters any Right values.

  40. final def collectM[R1 <: R, E1 >: E, O1](pf: PartialFunction[O, ZIO[R1, E1, O1]]): ZStream[R1, E1, O1]

    Performs an effectful filter and map in a single step.

  41. final def collectRight[L1, O1](implicit ev: <:<[O, Either[L1, O1]]): ZStream[R, E, O1]

    Filters any Left values.

  42. final def collectSome[O1](implicit ev: <:<[O, Option[O1]]): ZStream[R, E, O1]

    Filters any 'None' values.

  43. final def collectSuccess[L1, O1](implicit ev: <:<[O, Exit[L1, O1]]): ZStream[R, E, O1]

    Filters any Exit.Failure values.

  44. def collectWhile[O2](p: PartialFunction[O, O2]): ZStream[R, E, O2]

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

  45. final def collectWhileLeft[L1, O1](implicit ev: <:<[O, Either[L1, O1]]): ZStream[R, E, L1]

    Terminates the stream when encountering the first Right.

  46. final def collectWhileM[R1 <: R, E1 >: E, O2](pf: PartialFunction[O, ZIO[R1, E1, O2]]): ZStream[R1, E1, O2]

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

  47. final def collectWhileRight[L1, O1](implicit ev: <:<[O, Either[L1, O1]]): ZStream[R, E, O1]

    Terminates the stream when encountering the first Left.

  48. final def collectWhileSome[O1](implicit ev: <:<[O, Option[O1]]): ZStream[R, E, O1]

    Terminates the stream when encountering the first None.

  49. final def collectWhileSuccess[L1, O1](implicit ev: <:<[O, Exit[L1, O1]]): ZStream[R, E, O1]

    Terminates the stream when encountering the first Exit.Failure.

  50. final def combine[R1 <: R, E1 >: E, S, O2, O3](that: ZStream[R1, E1, O2])(s: S)(f: (S, ZIO[R, Option[E], O], ZIO[R1, Option[E1], O2]) => ZIO[R1, Nothing, Exit[Option[E1], (O3, S)]]): ZStream[R1, E1, O3]

    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.

    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.

  51. final def combineChunks[R1 <: R, E1 >: E, S, O2, O3](that: ZStream[R1, E1, O2])(s: S)(f: (S, ZIO[R, Option[E], Chunk[O]], ZIO[R1, Option[E1], Chunk[O2]]) => ZIO[R1, Nothing, Exit[Option[E1], (Chunk[O3], S)]]): ZStream[R1, E1, O3]

    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.

    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.

  52. def concat[R1 <: R, E1 >: E, O1 >: O](that: => ZStream[R1, E1, O1]): ZStream[R1, E1, O1]

    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.

  53. final def cross[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, (O, O2)]

    Composes this stream with the specified stream to create a cartesian product of elements.

    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.

  54. final def crossLeft[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O]

    Composes this stream with the specified stream to create a cartesian product of elements, but keeps only elements from 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.

  55. final def crossRight[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    Composes this stream with the specified stream to create a cartesian product of elements, but keeps only elements from the other 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.

  56. final def crossWith[R1 <: R, E1 >: E, O2, C](that: ZStream[R1, E1, O2])(f: (O, O2) => C): ZStream[R1, E1, C]

    Composes this stream with the specified stream to create a cartesian product of elements with a specified function.

    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.

  57. final def debounce[E1 >: E, O2 >: O](d: Duration): ZStream[R with Clock, E1, O2]
  58. final def distributedWith[E1 >: E](n: Int, maximumLag: Int, decide: (O) => UIO[(Int) => Boolean]): ZManaged[R, Nothing, List[Dequeue[Exit[Option[E1], O]]]]

    More powerful version of ZStream#broadcast.

    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.

  59. final def distributedWithDynamic(maximumLag: Int, decide: (O) => UIO[(UniqueKey) => Boolean], done: (Exit[Option[E], Nothing]) => UIO[Any] = (_: Any) => UIO.unit): ZManaged[R, Nothing, UIO[(UniqueKey, Dequeue[Exit[Option[E], O]])]]

    More powerful version of ZStream#distributedWith.

    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.

  60. final def drain: ZStream[R, E, Nothing]

    Converts this stream to a stream that executes its effects but emits no elements.

    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.fromEffect(ZIO(println("Done!"))).drain ++
      Stream(4, 5, 6).tap(i => ZIO(println(i)))).run(Sink.drain)
  61. final def drainFork[R1 <: R, E1 >: E](other: ZStream[R1, E1, Any]): ZStream[R1, E1, O]

    Drains the provided stream in the background for as long as this stream is running.

    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.

  62. def drop(n: Long): ZStream[R, E, O]

    Drops the specified number of elements from this stream.

  63. final def dropUntil(pred: (O) => Boolean): ZStream[R, E, O]

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

  64. def dropWhile(pred: (O) => Boolean): ZStream[R, E, O]

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

  65. final def either(implicit ev: CanFail[E]): ZStream[R, Nothing, Either[E, O]]

    Returns a stream whose failures and successes have been lifted into an Either.

    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.

  66. final def ensuring[R1 <: R](fin: ZIO[R1, Nothing, Any]): ZStream[R1, E, O]

    Executes the provided finalizer after this stream's finalizers run.

  67. final def ensuringFirst[R1 <: R](fin: ZIO[R1, Nothing, Any]): ZStream[R1, E, O]

    Executes the provided finalizer before this stream's finalizers run.

  68. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  69. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  70. def filter(f: (O) => Boolean): ZStream[R, E, O]

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

  71. def filterM[R1 <: R, E1 >: E](f: (O) => ZIO[R1, E1, Boolean]): ZStream[R1, E1, O]

    Effectfully filters the elements emitted by this stream.

  72. final def filterNot(pred: (O) => Boolean): ZStream[R, E, O]

    Filters this stream by the specified predicate, removing all elements for which the predicate evaluates to true.

  73. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  74. final def fixed(duration: Duration): ZStream[R with Clock, E, O]

    Emits elements of this stream with a fixed delay in between, regardless of how long it takes to produce a value.

  75. def flatMap[R1 <: R, E1 >: E, O2](f0: (O) => ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    Returns a stream made of the concatenation in strict order of all the streams produced by passing each element of this stream to f0

  76. final def flatMapPar[R1 <: R, E1 >: E, O2](n: Int, outputBuffer: Int = 16)(f: (O) => ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    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.

    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 outputBuffer elements of the produced streams may be buffered in memory by this operator.

  77. final def flatMapParSwitch[R1 <: R, E1 >: E, O2](n: Int, bufferSize: Int = 16)(f: (O) => ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    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.

    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.

  78. def flatten[R1 <: R, E1 >: E, O1](implicit ev: <:<[O, ZStream[R1, E1, O1]]): ZStream[R1, E1, O1]

    Flattens this stream-of-streams into a stream made of the concatenation in strict order of all the streams.

  79. def flattenChunks[O1](implicit ev: <:<[O, Chunk[O1]]): ZStream[R, E, O1]

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

  80. def flattenExit[E1 >: E, O1](implicit ev: <:<[O, Exit[E1, O1]]): ZStream[R, E1, O1]

    Flattens Exit values.

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

  81. def flattenExitOption[E1 >: E, O1](implicit ev: <:<[O, Exit[Option[E1], O1]]): ZStream[R, E1, O1]

    Unwraps Exit values that also signify end-of-stream by failing with None.

    Unwraps Exit values that also signify end-of-stream by failing with None.

    For Exit[E, O] values that do not signal end-of-stream, prefer:

    stream.mapM(ZIO.done(_))
  82. def flattenIterables[O1](implicit ev: <:<[O, Iterable[O1]]): ZStream[R, E, O1]

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

  83. def flattenPar[R1 <: R, E1 >: E, O1](n: Int, outputBuffer: Int = 16)(implicit ev: <:<[O, ZStream[R1, E1, O1]]): ZStream[R1, E1, O1]

    Flattens a stream of streams into a stream by executing a non-deterministic concurrent merge.

    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.

  84. def flattenParUnbounded[R1 <: R, E1 >: E, O1](outputBuffer: Int = 16)(implicit ev: <:<[O, ZStream[R1, E1, O1]]): ZStream[R1, E1, O1]

    Like flattenPar, but executes all streams concurrently.

  85. final def flattenTake[E1 >: E, O1](implicit ev: <:<[O, Take[E1, O1]]): ZStream[R, E1, O1]

    Unwraps Exit values and flatten chunks that also signify end-of-stream by failing with None.

  86. final def fold[S](s: S)(f: (S, O) => S): ZIO[R, E, S]

    Executes a pure fold over the stream of values - reduces all elements in the stream to a value of type S.

  87. final def foldM[R1 <: R, E1 >: E, S](s: S)(f: (S, O) => ZIO[R1, E1, S]): ZIO[R1, E1, S]

    Executes an effectful fold over the stream of values.

  88. final def foldManaged[S](s: S)(f: (S, O) => S): ZManaged[R, E, S]

    Executes a pure fold over the stream of values.

    Executes a pure fold over the stream of values. Returns a Managed value that represents the scope of the stream.

  89. final def foldManagedM[R1 <: R, E1 >: E, S](s: S)(f: (S, O) => ZIO[R1, E1, S]): ZManaged[R1, E1, S]

    Executes an effectful fold over the stream of values.

    Executes an effectful fold over the stream of values. Returns a Managed value that represents the scope of the stream.

  90. final def foldWhile[S](s: S)(cont: (S) => Boolean)(f: (S, O) => S): ZIO[R, E, S]

    Reduces the elements in the stream to a value of type S.

    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
  91. final def foldWhileM[R1 <: R, E1 >: E, S](s: S)(cont: (S) => Boolean)(f: (S, O) => ZIO[R1, E1, S]): ZIO[R1, E1, S]

    Executes an effectful fold over the stream of values.

    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) => UIO(s + a))  // UIO[Int] == 5
    cont

    function which defines the early termination condition

  92. def foldWhileManaged[S](s: S)(cont: (S) => Boolean)(f: (S, O) => S): ZManaged[R, E, S]

    Executes a pure fold over the stream of values.

    Executes a pure fold over the stream of values. Returns a Managed value that represents the scope of the stream. Stops the fold early when the condition is not fulfilled.

  93. final def foldWhileManagedM[R1 <: R, E1 >: E, S](s: S)(cont: (S) => Boolean)(f: (S, O) => ZIO[R1, E1, S]): ZManaged[R1, E1, S]

    Executes an effectful fold over the stream of values.

    Executes an effectful fold over the stream of values. Returns a Managed 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) => UIO(s + a))  // Managed[Nothing, Int]
      .use(ZIO.succeed)                       // UIO[Int] == 5
    cont

    function which defines the early termination condition

  94. final def foreach[R1 <: R, E1 >: E](f: (O) => ZIO[R1, E1, Any]): ZIO[R1, E1, Unit]

    Consumes all elements of the stream, passing them to the specified callback.

  95. final def foreachChunk[R1 <: R, E1 >: E](f: (Chunk[O]) => ZIO[R1, E1, Any]): ZIO[R1, E1, Unit]

    Consumes all elements of the stream, passing them to the specified callback.

  96. final def foreachChunkManaged[R1 <: R, E1 >: E](f: (Chunk[O]) => ZIO[R1, E1, Any]): ZManaged[R1, E1, Unit]

    Like ZStream#foreachChunk, but returns a ZManaged so the finalization order can be controlled.

  97. final def foreachManaged[R1 <: R, E1 >: E](f: (O) => ZIO[R1, E1, Any]): ZManaged[R1, E1, Unit]

    Like ZStream#foreach, but returns a ZManaged so the finalization order can be controlled.

  98. final def foreachWhile[R1 <: R, E1 >: E](f: (O) => ZIO[R1, E1, Boolean]): ZIO[R1, E1, Unit]

    Consumes elements of the stream, passing them to the specified callback, and terminating consumption when the callback returns false.

  99. final def foreachWhileManaged[R1 <: R, E1 >: E](f: (O) => ZIO[R1, E1, Boolean]): ZManaged[R1, E1, Unit]

    Like ZStream#foreachWhile, but returns a ZManaged so the finalization order can be controlled.

  100. def forever: ZStream[R, E, O]

    Repeats this stream forever.

  101. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  102. final def groupBy[R1 <: R, E1 >: E, K, V](f: (O) => ZIO[R1, E1, (K, V)], buffer: Int = 16): GroupBy[R1, E1, K, V]

    More powerful version of ZStream.groupByKey

  103. final def groupByKey[K](f: (O) => K, buffer: Int = 16): GroupBy[R, E, K, O]

    Partition a stream using a function and process each stream individually.

    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"))
  104. def grouped(chunkSize: Int): ZStream[R, E, Chunk[O]]

    Partitions the stream with specified chunkSize

    Partitions the stream with specified chunkSize

    chunkSize

    size of the chunk

  105. def groupedWithin(chunkSize: Int, within: Duration): ZStream[R with Clock, E, Chunk[O]]

    Partitions the stream with the specified chunkSize or until the specified duration has passed, whichever is satisfied first.

  106. final def haltAfter(duration: Duration): ZStream[R with Clock, E, O]

    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.

  107. final def haltWhen[E1 >: E](p: Promise[E1, _]): ZStream[R, E1, O]

    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.

  108. final def haltWhen[R1 <: R, E1 >: E](io: ZIO[R1, E1, Any]): ZStream[R1, E1, O]

    Halts the evaluation of this stream when the provided IO completes.

    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.

  109. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  110. final def interleave[R1 <: R, E1 >: E, O1 >: O](that: ZStream[R1, E1, O1]): ZStream[R1, E1, O1]

    Interleaves this stream and the specified stream deterministically by alternating pulling values from this stream and the specified stream.

    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.

  111. final def interleaveWith[R1 <: R, E1 >: E, O1 >: O](that: ZStream[R1, E1, O1])(b: ZStream[R1, E1, Boolean]): ZStream[R1, E1, O1]

    Combines this stream and the specified stream deterministically using the stream of boolean values b to control which stream to pull from next.

    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.

  112. final def interruptAfter(duration: Duration): ZStream[R with Clock, E, O]

    Specialized version of interruptWhen which interrupts the evaluation of this stream after the given duration.

  113. final def interruptWhen[E1 >: E](p: Promise[E1, _]): ZStream[R, E1, O]

    Interrupts the evaluation of this stream when the provided promise resolves.

    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.

  114. final def interruptWhen[R1 <: R, E1 >: E](io: ZIO[R1, E1, Any]): ZStream[R1, E1, O]

    Interrupts the evaluation of this stream when the provided IO completes.

    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.

  115. final def intersperse[O1 >: O](start: O1, middle: O1, end: O1): ZStream[R, E, O1]

    Intersperse and also add a prefix and a suffix

  116. final def intersperse[O1 >: O](middle: O1): ZStream[R, E, O1]

    Intersperse stream with provided element similar to List.mkString.

  117. final def into[R1 <: R, E1 >: E](queue: ZQueue[R1, Nothing, Nothing, Any, Take[E1, O], Any]): ZIO[R1, E1, Unit]

    Enqueues elements of this stream into a queue.

    Enqueues elements of this stream into a queue. Stream failure and ending will also be signalled.

  118. final def intoHub[R1 <: R, E1 >: E](hub: ZHub[R1, Nothing, Nothing, Any, Take[E1, O], Any]): ZIO[R1, E1, Unit]

    Publishes elements of this stream to a hub.

    Publishes elements of this stream to a hub. Stream failure and ending will also be signalled.

  119. final def intoHubManaged[R1 <: R, E1 >: E](hub: ZHub[R1, Nothing, Nothing, Any, Take[E1, O], Any]): ZManaged[R1, E1, Unit]

    Like ZStream#intoHub, but provides the result as a ZManaged to allow for scope composition.

  120. final def intoManaged[R1 <: R, E1 >: E](queue: ZQueue[R1, Nothing, Nothing, Any, Take[E1, O], Any]): ZManaged[R1, E1, Unit]

    Like ZStream#into, but provides the result as a ZManaged to allow for scope composition.

  121. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  122. def lock(executor: Executor): ZStream[R, E, O]

    Locks the execution of this stream to the specified 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.

  123. def map[O2](f: (O) => O2): ZStream[R, E, O2]

    Transforms the elements of this stream using the supplied function.

  124. def mapAccum[S, O1](s: S)(f: (S, O) => (S, O1)): ZStream[R, E, O1]

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

  125. final def mapAccumM[R1 <: R, E1 >: E, S, O1](s: S)(f: (S, O) => ZIO[R1, E1, (S, O1)]): ZStream[R1, E1, O1]

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

  126. def mapBoth[E1, O1](f: (E) => E1, g: (O) => O1)(implicit ev: CanFail[E]): ZStream[R, E1, O1]

    Returns a stream whose failure and success channels have been mapped by the specified pair of functions, f and g.

  127. def mapChunks[O2](f: (Chunk[O]) => Chunk[O2]): ZStream[R, E, O2]

    Transforms the chunks emitted by this stream.

  128. def mapChunksM[R1 <: R, E1 >: E, O2](f: (Chunk[O]) => ZIO[R1, E1, Chunk[O2]]): ZStream[R1, E1, O2]

    Effectfully transforms the chunks emitted by this stream.

  129. def mapConcat[O2](f: (O) => Iterable[O2]): ZStream[R, E, O2]

    Maps each element to an iterable, and flattens the iterables into the output of this stream.

  130. def mapConcatChunk[O2](f: (O) => Chunk[O2]): ZStream[R, E, O2]

    Maps each element to a chunk, and flattens the chunks into the output of this stream.

  131. final def mapConcatChunkM[R1 <: R, E1 >: E, O2](f: (O) => ZIO[R1, E1, Chunk[O2]]): ZStream[R1, E1, O2]

    Effectfully maps each element to a chunk, and flattens the chunks into the output of this stream.

  132. final def mapConcatM[R1 <: R, E1 >: E, O2](f: (O) => ZIO[R1, E1, Iterable[O2]]): ZStream[R1, E1, O2]

    Effectfully maps each element to an iterable, and flattens the iterables into the output of this stream.

  133. def mapError[E2](f: (E) => E2): ZStream[R, E2, O]

    Transforms the errors emitted by this stream using f.

  134. def mapErrorCause[E2](f: (Cause[E]) => Cause[E2]): ZStream[R, E2, O]

    Transforms the full causes of failures emitted by this stream.

  135. def mapM[R1 <: R, E1 >: E, O2](f: (O) => ZIO[R1, E1, O2]): ZStream[R1, E1, O2]

    Maps over elements of the stream with the specified effectful function.

  136. final def mapMPar[R1 <: R, E1 >: E, O2](n: Int)(f: (O) => ZIO[R1, E1, O2]): ZStream[R1, E1, O2]

    Maps over elements of the stream with the specified effectful function, executing up to n invocations of f concurrently.

    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.

  137. final def mapMParUnordered[R1 <: R, E1 >: E, O2](n: Int)(f: (O) => ZIO[R1, E1, O2]): ZStream[R1, E1, O2]

    Maps over elements of the stream with the specified effectful function, executing up to n invocations of f concurrently.

    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.

  138. final def mapMPartitioned[R1 <: R, E1 >: E, O2, K](keyBy: (O) => K, buffer: Int = 16)(f: (O) => ZIO[R1, E1, O2]): ZStream[R1, E1, O2]

    Maps over elements of the stream with the specified effectful function, partitioned by p executing invocations of f concurrently.

    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.

  139. final def merge[R1 <: R, E1 >: E, O1 >: O](that: ZStream[R1, E1, O1], strategy: TerminationStrategy = TerminationStrategy.Both): ZStream[R1, E1, O1]

    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.

  140. final def mergeEither[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, Either[O, O2]]

    Merges this stream and the specified stream together to produce a stream of eithers.

  141. final def mergeTerminateEither[R1 <: R, E1 >: E, O1 >: O](that: ZStream[R1, E1, O1]): ZStream[R1, E1, O1]

    Merges this stream and the specified stream together.

    Merges this stream and the specified stream together. New produced stream will terminate when either stream terminates.

  142. final def mergeTerminateLeft[R1 <: R, E1 >: E, O1 >: O](that: ZStream[R1, E1, O1]): ZStream[R1, E1, O1]

    Merges this stream and the specified stream together.

    Merges this stream and the specified stream together. New produced stream will terminate when this stream terminates.

  143. final def mergeTerminateRight[R1 <: R, E1 >: E, O1 >: O](that: ZStream[R1, E1, O1]): ZStream[R1, E1, O1]

    Merges this stream and the specified stream together.

    Merges this stream and the specified stream together. New produced stream will terminate when the specified stream terminates.

  144. final def mergeWith[R1 <: R, E1 >: E, O2, O3](that: ZStream[R1, E1, O2], strategy: TerminationStrategy = TerminationStrategy.Both)(l: (O) => O3, r: (O2) => O3): ZStream[R1, E1, O3]

    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.

  145. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  146. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  147. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  148. final def onError[R1 <: R](cleanup: (Cause[E]) => URIO[R1, Any]): ZStream[R1, E, O]

    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.

  149. final def orElse[R1 <: R, E2, O1 >: O](that: => ZStream[R1, E2, O1])(implicit ev: CanFail[E]): ZStream[R1, E2, O1]

    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.

  150. final def orElseEither[R1 <: R, E2, O2](that: => ZStream[R1, E2, O2])(implicit ev: CanFail[E]): ZStream[R1, E2, Either[O, O2]]

    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.

  151. final def orElseFail[E1](e1: => E1)(implicit ev: CanFail[E]): ZStream[R, E1, O]

    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.

  152. final def orElseOptional[R1 <: R, E1, O1 >: O](that: => ZStream[R1, Option[E1], O1])(implicit ev: <:<[E, Option[E1]]): ZStream[R1, Option[E1], O1]

    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.

  153. final def orElseSucceed[O1 >: O](o1: => O1)(implicit ev: CanFail[E]): ZStream[R, Nothing, O1]

    Succeeds with the specified value if this one fails with a typed error.

  154. def partition(p: (O) => Boolean, buffer: Int = 16): ZManaged[R, E, (ZStream[Any, E, O], ZStream[Any, E, O])]

    Partition a stream using a predicate.

    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.

  155. final def partitionEither[R1 <: R, E1 >: E, O2, O3](p: (O) => ZIO[R1, E1, Either[O2, O3]], buffer: Int = 16): ZManaged[R1, E1, (ZStream[Any, E1, O2], ZStream[Any, E1, O3])]

    Split a stream by a predicate.

    Split a stream by a predicate. The faster stream may advance by up to buffer elements further than the slower one.

  156. def peel[R1 <: R, E1 >: E, O1 >: O, Z](sink: ZSink[R1, E1, O, O1, Z]): ZManaged[R1, E1, (Z, ZStream[R, E, O1])]

    Peels off enough material from the stream to construct a Z using the provided ZSink and then returns both the Z and the rest of the ZStream in a managed resource.

    Peels off enough material from the stream to construct a Z using the provided ZSink and then returns both the Z and the rest of the ZStream in a managed resource. Like all ZManaged values, the provided stream is valid only within the scope of ZManaged.

  157. val process: ZManaged[R, Nothing, ZIO[R, Option[E], Chunk[O]]]
  158. final def provide(r: R)(implicit ev: NeedsEnv[R]): ZStream[Any, E, O]

    Provides the stream with its required environment, which eliminates its dependency on R.

  159. def provideCustomLayer[E1 >: E, R1 <: Has[_]](layer: ZLayer[zio.ZEnv, E1, R1])(implicit ev: <:<[zio.ZEnv with R1, R], tagged: zio.Tag[R1]): ZStream[zio.ZEnv, E1, O]

    Provides the part of the environment that is not part of the ZEnv, leaving a stream that only depends on the ZEnv.

    Provides the part of the environment that is not part of the ZEnv, leaving a stream that only depends on the ZEnv.

    val loggingLayer: ZLayer[Any, Nothing, Logging] = ???
    
    val stream: ZStream[ZEnv with Logging, Nothing, Unit] = ???
    
    val stream2 = stream.provideCustomLayer(loggingLayer)
  160. final def provideLayer[E1 >: E, R0, R1](layer: ZLayer[R0, E1, R1])(implicit ev1: <:<[R1, R], ev2: NeedsEnv[R]): ZStream[R0, E1, O]

    Provides a layer to the stream, which translates it to another level.

  161. final def provideSome[R0](env: (R0) => R)(implicit ev: NeedsEnv[R]): ZStream[R0, E, O]

    Provides some of the environment required to run this effect, leaving the remainder R0.

  162. final def provideSomeLayer[R0 <: Has[_]]: ProvideSomeLayer[R0, R, E, O]

    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 clockLayer: ZLayer[Any, Nothing, Clock] = ???
    
    val stream: ZStream[Clock with Random, Nothing, Unit] = ???
    
    val stream2 = stream.provideSomeLayer[Random](clockLayer)
  163. final def refineOrDie[E1](pf: PartialFunction[E, E1])(implicit ev1: <:<[E, Throwable], ev2: CanFail[E]): ZStream[R, E1, O]

    Keeps some of the errors, and terminates the fiber with the rest

  164. final def refineOrDieWith[E1](pf: PartialFunction[E, E1])(f: (E) => Throwable)(implicit ev: CanFail[E]): ZStream[R, E1, O]

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

  165. final def repeat[R1 <: R, B](schedule: Schedule[R1, Any, B]): ZStream[R1 with Clock, E, O]

    Repeats the entire stream using the specified schedule.

    Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule.

  166. final def repeatEither[R1 <: R, B](schedule: Schedule[R1, Any, B]): ZStream[R1 with Clock, E, Either[B, O]]

    Repeats the entire stream using the specified 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.

  167. final def repeatElements[R1 <: R](schedule: Schedule[R1, O, Any]): ZStream[R1 with Clock, E, O]

    Repeats each element of the stream using the provided schedule.

    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.

  168. final def repeatElementsEither[R1 <: R, E1 >: E, B](schedule: Schedule[R1, O, B]): ZStream[R1 with Clock, E1, Either[B, O]]

    Repeats each element of the stream using the provided schedule.

    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.

  169. final def repeatElementsWith[R1 <: R, E1 >: E, B, C](schedule: Schedule[R1, O, B])(f: (O) => C, g: (B) => C): ZStream[R1 with Clock, E1, C]

    Repeats each element of the stream using the provided schedule.

    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.

  170. final def repeatWith[R1 <: R, B, C](schedule: Schedule[R1, Any, B])(f: (O) => C, g: (B) => C): ZStream[R1 with Clock, E, C]

    Repeats the entire stream using the specified 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 and can be unified with the stream elements using the provided functions.

  171. def retry[R1 <: R](schedule: Schedule[R1, E, _]): ZStream[R1 with Clock, E, O]

    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.

    schedule

    Schedule receiving as input the errors of the stream

    returns

    Stream outputting elements of all attempts of the stream

  172. final def right[O1, O2](implicit ev: <:<[O, Either[O1, O2]]): ZStream[R, Option[E], O2]

    Fails with the error None if value is Left.

  173. final def rightOrFail[O1, O2, E1 >: E](e: => E1)(implicit ev: <:<[O, Either[O1, O2]]): ZStream[R, E1, O2]

    Fails with given error 'e' if value is Left.

  174. def run[R1 <: R, E1 >: E, B](sink: ZSink[R1, E1, O, Any, B]): ZIO[R1, E1, B]

    Runs the sink on the stream to produce either the sink's result or an error.

  175. def runCollect: ZIO[R, E, Chunk[O]]

    Runs the stream and collects all of its elements to a chunk.

  176. final def runCount: ZIO[R, E, Long]

    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)

  177. def runDrain: ZIO[R, E, Unit]

    Runs the stream only for its effects.

    Runs the stream only for its effects. The emitted elements are discarded.

  178. def runHead: ZIO[R, E, Option[O]]

    Runs the stream to collect the first value emitted by it without running the rest of the stream.

  179. def runLast: ZIO[R, E, Option[O]]

    Runs the stream to completion and yields the last value emitted by it, discarding the rest of the elements.

  180. def runManaged[R1 <: R, E1 >: E, B](sink: ZSink[R1, E1, O, Any, B]): ZManaged[R1, E1, B]
  181. final def runSum[O1 >: O](implicit ev: Numeric[O1]): ZIO[R, E, O1]

    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])

  182. def scan[S](s: S)(f: (S, O) => S): ZStream[R, E, S]

    Statefully maps over the elements of this stream to produce all intermediate results of type S given an initial S.

  183. def scanM[R1 <: R, E1 >: E, S](s: S)(f: (S, O) => ZIO[R1, E1, S]): ZStream[R1, E1, S]

    Statefully and effectfully maps over the elements of this stream to produce all intermediate results of type S given an initial S.

  184. def scanReduce[O1 >: O](f: (O1, O) => O1): ZStream[R, E, O1]

    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.

  185. def scanReduceM[R1 <: R, E1 >: E, O1 >: O](f: (O1, O) => ZIO[R1, E1, O1]): ZStream[R1, E1, O1]

    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#scanM.

  186. final def schedule[R1 <: R](schedule: Schedule[R1, O, Any]): ZStream[R1 with Clock, E, O]

    Schedules the output of the stream using the provided schedule.

  187. final def scheduleEither[R1 <: R, E1 >: E, B](schedule: Schedule[R1, O, B]): ZStream[R1 with Clock, E1, Either[B, O]]

    Schedules the output of the stream using the provided schedule and emits its output at the end (if schedule is finite).

  188. final def scheduleWith[R1 <: R, E1 >: E, B, C](schedule: Schedule[R1, O, B])(f: (O) => C, g: (B) => C): ZStream[R1 with Clock, E1, C]

    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.

  189. final def some[O2](implicit ev: <:<[O, Option[O2]]): ZStream[R, Option[E], O2]

    Converts an option on values into an option on errors.

  190. final def someOrElse[O2](default: => O2)(implicit ev: <:<[O, Option[O2]]): ZStream[R, E, O2]

    Extracts the optional value, or returns the given 'default'.

  191. final def someOrFail[O2, E1 >: E](e: => E1)(implicit ev: <:<[O, Option[O2]]): ZStream[R, E1, O2]

    Extracts the optional value, or fails with the given error 'e'.

  192. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  193. def take(n: Long): ZStream[R, E, O]

    Takes the specified number of elements from this stream.

  194. def takeRight(n: Int): ZStream[R, E, O]

    Takes the last specified number of elements from this stream.

  195. def takeUntil(pred: (O) => Boolean): ZStream[R, E, O]

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

  196. def takeUntilM[R1 <: R, E1 >: E](pred: (O) => ZIO[R1, E1, Boolean]): ZStream[R1, E1, O]

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

  197. def takeWhile(pred: (O) => Boolean): ZStream[R, E, O]

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

  198. final def tap[R1 <: R, E1 >: E](f0: (O) => ZIO[R1, E1, Any]): ZStream[R1, E1, O]

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

  199. final def tapError[R1 <: R, E1 >: E](f: (E) => ZIO[R1, E1, Any])(implicit ev: CanFail[E]): ZStream[R1, E1, O]

    Returns a stream that effectfully "peeks" at the failure of the stream.

  200. final def throttleEnforce(units: Long, duration: Duration, burst: Long = 0)(costFn: (Chunk[O]) => Long): ZStream[R with Clock, E, O]

    Throttles the chunks of this stream according to the given bandwidth parameters using the token bucket algorithm.

    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.

  201. final def throttleEnforceM[R1 <: R, E1 >: E](units: Long, duration: Duration, burst: Long = 0)(costFn: (Chunk[O]) => ZIO[R1, E1, Long]): ZStream[R1 with Clock, E1, O]

    Throttles the chunks of this stream according to the given bandwidth parameters using the token bucket algorithm.

    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.

  202. final def throttleShape(units: Long, duration: Duration, burst: Long = 0)(costFn: (Chunk[O]) => Long): ZStream[R with Clock, E, O]

    Delays the chunks of this stream according to the given bandwidth parameters using the token bucket algorithm.

    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.

  203. final def throttleShapeM[R1 <: R, E1 >: E](units: Long, duration: Duration, burst: Long = 0)(costFn: (Chunk[O]) => ZIO[R1, E1, Long]): ZStream[R1 with Clock, E1, O]

    Delays the chunks of this stream according to the given bandwidth parameters using the token bucket algorithm.

    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.

  204. final def timeout(d: Duration): ZStream[R with Clock, E, O]

    Ends the stream if it does not produce a value after d duration.

  205. final def timeoutError[E1 >: E](e: => E1)(d: Duration): ZStream[R with Clock, E1, O]

    Fails the stream with given error if it does not produce a value after d duration.

  206. final def timeoutErrorCause[E1 >: E](cause: Cause[E1])(d: Duration): ZStream[R with Clock, E1, O]

    Halts the stream with given cause if it does not produce a value after d duration.

  207. final def timeoutTo[R1 <: R, E1 >: E, O2 >: O](d: Duration)(that: ZStream[R1, E1, O2]): ZStream[R1 with Clock, E1, O2]

    Switches the stream if it does not produce a value after d duration.

  208. def toHub(capacity: Int): ZManaged[R, Nothing, ZHub[Nothing, Any, Any, Nothing, Nothing, Take[E, O]]]

    Converts the stream to a managed hub of chunks.

    Converts the stream to a managed hub of chunks. After the managed hub is used, the hub will never again produce values and should be discarded.

  209. def toInputStream(implicit ev0: <:<[E, Throwable], ev1: <:<[O, Byte]): ZManaged[R, E, InputStream]

    Converts this stream of bytes into a java.io.InputStream wrapped in a ZManaged.

    Converts this stream of bytes into a java.io.InputStream wrapped in a ZManaged. The returned input stream will only be valid within the scope of the ZManaged.

  210. def toIterator: ZManaged[R, Nothing, Iterator[Either[E, O]]]

    Converts this stream into a scala.collection.Iterator wrapped in a ZManaged.

    Converts this stream into a scala.collection.Iterator wrapped in a ZManaged. The returned iterator will only be valid within the scope of the ZManaged.

  211. final def toQueue(capacity: Int = 2): ZManaged[R, Nothing, Dequeue[Take[E, O]]]

    Converts the stream to a managed queue of chunks.

    Converts the stream to a managed queue of chunks. After the managed queue is used, the queue will never again produce values and should be discarded.

  212. final def toQueueUnbounded: ZManaged[R, Nothing, Dequeue[Take[E, O]]]

    Converts the stream into an unbounded managed queue.

    Converts the stream into an unbounded managed queue. After the managed queue is used, the queue will never again produce values and should be discarded.

  213. def toReader(implicit ev0: <:<[E, Throwable], ev1: <:<[O, Char]): ZManaged[R, E, Reader]

    Converts this stream of chars into a java.io.Reader wrapped in a ZManaged.

    Converts this stream of chars into a java.io.Reader wrapped in a ZManaged. The returned reader will only be valid within the scope of the ZManaged.

  214. def toString(): String
    Definition Classes
    AnyRef → Any
  215. def transduce[R1 <: R, E1 >: E, O3](transducer: ZTransducer[R1, E1, O, O3]): ZStream[R1, E1, O3]

    Applies the transducer to the stream and emits its outputs.

  216. final def updateService[M]: UpdateService[R, E, O, M]

    Updates a service in the environment of this effect.

  217. final def via[R2, E2, O2](f: (ZStream[R, E, O]) => ZStream[R2, E2, O2]): ZStream[R2, E2, O2]

    Threads the stream through the transformation function f.

  218. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  219. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  220. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  221. def when(b: => Boolean): ZStream[R, E, O]

    Returns this stream if the specified condition is satisfied, otherwise returns an empty stream.

  222. def whenM[R1 <: R, E1 >: E](b: ZIO[R1, E1, Boolean]): ZStream[R1, E1, O]

    Returns this stream if the specified effectful condition is satisfied, otherwise returns an empty stream.

  223. def withFilter(predicate: (O) => Boolean): ZStream[R, E, O]

    Equivalent to filter but enables the use of filter clauses in for-comprehensions

  224. def zip[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, (O, O2)]

    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.

  225. def zipAll[R1 <: R, E1 >: E, O1 >: O, O2](that: ZStream[R1, E1, O2])(defaultLeft: O1, defaultRight: O2): ZStream[R1, E1, (O1, O2)]

    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.

  226. def zipAllLeft[R1 <: R, E1 >: E, O1 >: O, O2](that: ZStream[R1, E1, O2])(default: O1): ZStream[R1, E1, O1]

    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.

  227. def zipAllRight[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2])(default: O2): ZStream[R1, E1, O2]

    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.

  228. def zipAllWith[R1 <: R, E1 >: E, O2, O3](that: ZStream[R1, E1, O2])(left: (O) => O3, right: (O2) => O3)(both: (O, O2) => O3): ZStream[R1, E1, O3]

    Zips this stream with another point-wise.

    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.

  229. def zipAllWithExec[R1 <: R, E1 >: E, O2, O3](that: ZStream[R1, E1, O2])(exec: ExecutionStrategy)(left: (O) => O3, right: (O2) => O3)(both: (O, O2) => O3): ZStream[R1, E1, O3]

    Zips this stream with another point-wise.

    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.

    The execution strategy exec will be used to determine whether to pull from the streams sequentially or in parallel.

  230. def zipLeft[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O]

    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.

  231. def zipRight[R1 <: R, E1 >: E, O2](that: ZStream[R1, E1, O2]): ZStream[R1, E1, O2]

    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.

  232. def zipWith[R1 <: R, E1 >: E, O2, O3](that: ZStream[R1, E1, O2])(f: (O, O2) => O3): ZStream[R1, E1, O3]

    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.

  233. final def zipWithIndex: ZStream[R, E, (O, Long)]

    Zips this stream together with the index of elements.

  234. final def zipWithLatest[R1 <: R, E1 >: E, O2, O3](that: ZStream[R1, E1, O2])(f: (O, O2) => O3): ZStream[R1, E1, O3]

    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.

  235. final def zipWithNext: ZStream[R, E, (O, Option[O])]

    Zips each element with the next element if present.

  236. final def zipWithPrevious: ZStream[R, E, (Option[O], O)]

    Zips each element with the previous element.

    Zips each element with the previous element. Initially accompanied by None.

  237. final def zipWithPreviousAndNext: ZStream[R, E, (Option[O], O, Option[O])]

    Zips each element with both the previous and next element.

Deprecated Value Members

  1. def bimap[E1, O1](f: (E) => E1, g: (O) => O1)(implicit ev: CanFail[E]): ZStream[R, E1, O1]

    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.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.0.0) use mapBoth

  2. final def foreachChunkWhile[R1 <: R, E1 >: E](f: (Chunk[O]) => ZIO[R1, E1, Boolean]): ZIO[R1, E1, Unit]

    Consumes chunks of the stream, passing them to the specified callback, and terminating consumption when the callback returns false.

    Consumes chunks of the stream, passing them to the specified callback, and terminating consumption when the callback returns false.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.0-RC21) Use foreachWhile

  3. final def foreachChunkWhileManaged[R1 <: R, E1 >: E](f: (Chunk[O]) => ZIO[R1, E1, Boolean]): ZManaged[R1, E1, Unit]

    Like ZStream#foreachChunkWhile, but returns a ZManaged so the finalization order can be controlled.

    Like ZStream#foreachChunkWhile, but returns a ZManaged so the finalization order can be controlled.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.0-RC21) use foreachWhileManaged

Inherited from AnyRef

Inherited from Any

Ungrouped