class ZStream[-R, +E, +A] extends Serializable
A Stream[E, A] represents an effectful stream that can produce values of
type A, or potentially fail with a value of type E.
Streams have a very similar API to Scala collections, making them immediately familiar to most developers. Unlike Scala collections, streams can be used on effectful streams of data, such as HTTP connections, files, and so forth.
Streams do not leak resources. This guarantee holds in the presence of early termination (not all of a stream is consumed), failure, or even interruption.
Thanks to only first-order types, appropriate variance annotations, and specialized effect type (ZIO), streams feature extremely good type inference and should almost never require specification of any type parameters.
- Self Type
- ZStream[R, E, A]
- Alphabetic
- By Inheritance
- ZStream
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def &>[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, B]
Operator alias for
zipRight - final def *>[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, B]
Composes this stream with the specified stream to create a cartesian product of elements and keeps only the elements from the
thatstream.Composes this stream with the specified stream to create a cartesian product of elements and keeps only the elements from the
thatstream. Thethatstream would be run multiple times, for every element in thethisstream.See also ZStream#zipWith and ZStream#<&> for the more common point-wise variant.
- final def ++[R1 <: R, E1 >: E, A1 >: A](other: => ZStream[R1, E1, A1]): ZStream[R1, E1, A1]
Concatenates with another stream in strict order
- final def <&[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, A]
Operator alias for
zipLeft - final def <&>[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, (A, B)]
Operator alias for
zip - final def <*[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, A]
Composes this stream with the specified stream to create a cartesian product of elements and keeps only the elements from the
thisstream.Composes this stream with the specified stream to create a cartesian product of elements and keeps only the elements from the
thisstream. Thethatstream would be run multiple times, for every element in thethisstream.See also ZStream#zipWith and ZStream#<&> for the more common point-wise variant.
- final def <*>[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, (A, B)]
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
thatstream would be run multiple times, for every element in thethisstream.See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def aggregate[R1 <: R, E1 >: E, A1 >: A, B](sink: ZSink[R1, E1, A1, A1, B]): ZStream[R1, E1, B]
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 Sink.foldWeightedM and Sink.foldUntilM for sinks that cover the common usecases.
- final def aggregateWithin[R1 <: R, E1 >: E, A1 >: A, B, C](sink: ZSink[R1, E1, A1, A1, B], schedule: ZSchedule[R1, Option[B], C]): ZStream[R1 with Clock, E1, B]
Uses
aggregateWithinEitherbut only returns theRightresults.Uses
aggregateWithinEitherbut only returns theRightresults.- R1
environment type
- E1
error type
- A1
type of the values consumed by the given sink
- B
type of the value produced by the given sink and consumed by the given schedule
- C
type of the value produced by the given schedule
- sink
used for the aggregation
- schedule
signalling for when to stop the aggregation
- returns
ZStream[R1 with Clock, E1, B]
- final def aggregateWithinEither[R1 <: R, E1 >: E, A1 >: A, B, C](sink: ZSink[R1, E1, A1, A1, B], schedule: ZSchedule[R1, Option[B], C]): ZStream[R1 with Clock, E1, Either[C, B]]
Aggregates elements using the provided sink until it signals completion, or the delay signalled by the schedule has passed.
Aggregates elements using the provided sink 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 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.
- R1
environment type
- E1
error type
- A1
type of the values consumed by the given sink
- B
type of the value produced by the given sink and consumed by the given schedule
- C
type of the value produced by the given schedule
- sink
used for the aggregation
- schedule
signalling for when to stop the aggregation
- returns
ZStream[R1 with Clock, E1, Either[C, B]]
- final def as[B](b: => B): ZStream[R, E, B]
Maps the success values of this stream to the specified constant value.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def bimap[E2, B](f: (E) => E2, g: (A) => B): ZStream[R, E2, B]
Returns a stream whose failure and success channels have been mapped by the specified pair of functions,
fandg. - final def broadcast[E1 >: E, A1 >: A](n: Int, maximumLag: Int): ZManaged[R, Nothing, List[ZStream[Any, E, A]]]
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 streamer will only ever advance of the maximumLag values before the slowest downstream stream.
- final def broadcastedQueues[E1 >: E, A1 >: A](n: Int, maximumLag: Int): ZManaged[R, Nothing, List[Queue[Take[E1, A1]]]]
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 elements before the driver is backpressured. The downstream queues will be provided with elements in the same order they are returned, so the fastest queue might have seen up to (maximumLag + 1) elements more than the slowest queue if it has a lower index than the slowest queue. During the finalizer the driver will wait for all queues to shutdown in order to signal completion. After the managed value is used, the queues will never again produce values and should be discarded.
- final def buffer(capacity: Int): ZStream[R, E, A]
Allows a faster producer to progress independently of a slower consumer by buffering up to
capacityelements in a queue.Allows a faster producer to progress independently of a slower consumer by buffering up to
capacityelements in a queue.- Note
Prefer capacities that are powers of 2 for better performance.
- final def bufferDropping(capacity: Int): ZStream[R, E, A]
Allows a faster producer to progress independently of a slower consumer by buffering up to
capacityelements in a dropping queue.Allows a faster producer to progress independently of a slower consumer by buffering up to
capacityelements in a dropping queue.- Note
Prefer capacities that are powers of 2 for better performance.
- final def bufferSliding(capacity: Int): ZStream[R, E, A]
Allows a faster producer to progress independently of a slower consumer by buffering up to
capacityelements in a sliding queue.Allows a faster producer to progress independently of a slower consumer by buffering up to
capacityelements in a sliding queue.- Note
Prefer capacities that are powers of 2 for better performance.
- final def bufferUnbounded: ZStream[R, E, A]
Allows a faster producer to progress independently of a slower consumer by buffering elements into an unbounded queue.
- final def catchAll[R1 <: R, E2, A1 >: A](f: (E) => ZStream[R1, E2, A1]): ZStream[R1, E2, A1]
Switches over to the stream produced by the provided function in case this one fails with a typed error.
- final def catchAllCause[R1 <: R, E2, A1 >: A](f: (Cause[E]) => ZStream[R1, E2, A1]): ZStream[R1, E2, A1]
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 errors, except external interruption.
- def chunkN(chunkSize: Int): ZStream[R, E, Chunk[A]]
Chunks the stream with specifed chunkSize
Chunks the stream with specifed chunkSize
- chunkSize
size of the chunk
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[B](pf: PartialFunction[A, B]): ZStream[R, E, B]
Performs a filter and map in a single step.
- def collectWhile[B](pred: PartialFunction[A, B]): ZStream[R, E, B]
Transforms all elements of the stream for as long as the specified partial function is defined.
- final def combine[R1 <: R, E1 >: E, A1 >: A, S1, B, C](that: ZStream[R1, E1, B])(s1: S1)(f0: (S1, Pull[R, E, A], Pull[R1, E1, B]) => ZIO[R1, E1, (S1, Take[E1, C])]): ZStream[R1, E1, C]
Combines this stream and the specified stream by repeatedly applying the function
f0to extract an element from the queues and conceptually "offer" it to the destination stream.Combines this stream and the specified stream by repeatedly applying the function
f0to extract an element from the queues and conceptually "offer" it to the destination stream.f0can maintain some internal state to control the combining process, with the initial state being specified bys1. - final def concat[R1 <: R, E1 >: E, A1 >: A](other: => ZStream[R1, E1, A1]): ZStream[R1, E1, A1]
Appends another stream to this stream.
Appends another stream to this stream. The concatenated stream will first emit the elements of this stream, and then emit the elements of the
otherstream. - final def cross[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, (A, B)]
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
thatstream would be run multiple times, for every element in thethisstream.See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
- final def crossWith[R1 <: R, E1 >: E, B, C](that: ZStream[R1, E1, B])(f: (A, B) => 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
thatstream would be run multiple times, for every element in thethisstream.See also ZStream#zip and ZStream#<&> for the more common point-wise variant.
- final def distributedDynamicWith[E1 >: E, A1 >: A](maximumLag: Int, decide: (A) => UIO[(Int) => Boolean], done: (Take[E1, Nothing]) => UIO[Any] = (_: Any) => UIO.unit): ZManaged[R, Nothing, UIO[(Int, Queue[Take[E1, A1]])]]
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 but before the queues are actually shutdown. 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. - final def distributedWith[E1 >: E, A1 >: A](n: Int, maximumLag: Int, decide: (A) => UIO[(Int) => Boolean]): ZManaged[R, Nothing, List[Queue[Take[E1, A1]]]]
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. - 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.lift(ZIO(println("Done!"))).drain ++ Stream(4, 5, 6).tap(i => ZIO(println(i)))).run(Sink.drain)
- final def drop(n: Int): ZStream[R, E, A]
Drops the specified number of elements from this stream.
- final def dropUntil(pred: (A) => Boolean): ZStream[R, E, A]
Drops all elements of the stream until the specified predicate evaluates to
true. - def dropWhile(pred: (A) => Boolean): ZStream[R, E, A]
Drops all elements of the stream for as long as the specified predicate evaluates to
true. - final def either: ZStream[R, Nothing, Either[E, A]]
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 theEithersuccess case.- Note
the stream will end as soon as the first error occurs.
- final def ensuring[R1 <: R](fin: ZIO[R1, Nothing, Any]): ZStream[R1, E, A]
Executes the provided finalizer after this stream's finalizers run.
- final def ensuringFirst[R1 <: R](fin: ZIO[R1, Nothing, Any]): ZStream[R1, E, A]
Executes the provided finalizer before this stream's finalizers run.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def filter(pred: (A) => Boolean): ZStream[R, E, A]
Filters this stream by the specified predicate, retaining all elements for which the predicate evaluates to true.
- final def filterM[R1 <: R, E1 >: E](pred: (A) => ZIO[R1, E1, Boolean]): ZStream[R1, E1, A]
Filters this stream by the specified effectful predicate, retaining all elements for which the predicate evaluates to true.
- final def filterNot(pred: (A) => Boolean): ZStream[R, E, A]
Filters this stream by the specified predicate, removing all elements for which the predicate evaluates to true.
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def fixed[R1 <: R, E1 >: E, A1 >: A](duration: Duration): ZStream[R1 with Clock, E1, A1]
Emits elements of this stream with a fixed delay in between, regardless of how long it takes to produce a value.
- final def flatMap[R1 <: R, E1 >: E, B](f0: (A) => ZStream[R1, E1, B]): ZStream[R1, E1, B]
Returns a stream made of the concatenation in strict order of all the streams produced by passing each element of this stream to
f0 - final def flatMapPar[R1 <: R, E1 >: E, B](n: Int, outputBuffer: Int = 16)(f: (A) => ZStream[R1, E1, B]): ZStream[R1, E1, B]
Maps each element of this stream to another stream and returns the non-deterministic merge of those streams, executing up to
ninner streams concurrently.Maps each element of this stream to another stream and returns the non-deterministic merge of those streams, executing up to
ninner streams concurrently. Up tooutputBufferelements of the produced streams may be buffered in memory by this operator. - final def flatMapParSwitch[R1 <: R, E1 >: E, B](n: Int, bufferSize: Int = 16)(f: (A) => ZStream[R1, E1, B]): ZStream[R1, E1, B]
Maps each element of this stream to another stream and returns the non-deterministic merge of those streams, executing up to
ninner streams concurrently.Maps each element of this stream to another stream and returns the non-deterministic merge of those streams, executing up to
ninner streams concurrently. When a new stream is created from an element of the source stream, the oldest executing stream is cancelled. Up tobufferSizeelements of the produced streams may be buffered in memory by this operator. - final def fold[A1 >: A, S](s: S)(f: (S, A1) => 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. - final def foldM[R1 <: R, E1 >: E, A1 >: A, S](s: S)(f: (S, A1) => ZIO[R1, E1, S]): ZIO[R1, E1, S]
Executes an effectful fold over the stream of values.
- final def foldManaged[A1 >: A, S](s: S)(f: (S, A1) => 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.
- final def foldManagedM[R1 <: R, E1 >: E, A1 >: A, S](s: S)(f: (S, A1) => 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.
- final def foldWhile[A1 >: A, S](s: S)(cont: (S) => Boolean)(f: (S, A1) => 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
- final def foldWhileM[R1 <: R, E1 >: E, A1 >: A, S](s: S)(cont: (S) => Boolean)(f: (S, A1) => 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
- def foldWhileManaged[A1 >: A, S](s: S)(cont: (S) => Boolean)(f: (S, A1) => 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.
- final def foldWhileManagedM[R1 <: R, E1 >: E, A1 >: A, S](s: S)(cont: (S) => Boolean)(f: (S, A1) => 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
- final def foreach[R1 <: R, E1 >: E](f: (A) => ZIO[R1, E1, Any]): ZIO[R1, E1, Unit]
Consumes all elements of the stream, passing them to the specified callback.
- final def foreachManaged[R1 <: R, E1 >: E](f: (A) => ZIO[R1, E1, Any]): ZManaged[R1, E1, Unit]
Like ZStream#foreach, but returns a
ZManagedso the finalization order can be controlled. - final def foreachWhile[R1 <: R, E1 >: E](f: (A) => 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. - final def foreachWhileManaged[R1 <: R, E1 >: E](f: (A) => ZIO[R1, E1, Boolean]): ZManaged[R1, E1, Unit]
Like ZStream#foreachWhile, but returns a
ZManagedso the finalization order can be controlled. - final def forever: ZStream[R, E, A]
Repeats this stream forever.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def groupBy[R1 <: R, E1 >: E, K, V](f: (A) => ZIO[R1, E1, (K, V)], buffer: Int = 16): GroupBy[R1, E1, K, V]
More powerful version of ZStream.groupByKey
- final def groupByKey[K](f: (A) => K, buffer: Int = 16): GroupBy[R, E, K, A]
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 apply on the GroupBy object, the remaining groups will be processed in parallel and the resulting streams merged in a nondeterministic fashion.
Up to
bufferelements may be buffered in a group stream until 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"))
- def grouped(chunkSize: Long): ZStream[R, E, List[A]]
Partitions the stream with specifed chunkSize
Partitions the stream with specifed chunkSize
- chunkSize
size of the chunk
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def interleave[R1 <: R, E1 >: E, A1 >: A](that: ZStream[R1, E1, A1]): ZStream[R1, E1, A1]
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.
- final def interleaveWith[R1 <: R, E1 >: E, A1 >: A](that: ZStream[R1, E1, A1])(b: ZStream[R1, E1, Boolean]): ZStream[R1, E1, A1]
Combines this stream and the specified stream deterministically using the stream of boolean values
bto control which stream to pull from next.Combines this stream and the specified stream deterministically using the stream of boolean values
bto control which stream to pull from next.trueindicates to pull from this stream andfalseindicates to pull from the specified stream. Only consumes as many elements as requested byb. If either this stream or the specified stream are exhausted further requests for values from that stream will be ignored. - final def into[R1 <: R, E1 >: E, A1 >: A](queue: ZQueue[R1, E1, Nothing, Any, Take[E1, A1], 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.
- final def intoManaged[R1 <: R, E1 >: E, A1 >: A](queue: ZQueue[R1, E1, Nothing, Any, Take[E1, A1], Any]): ZManaged[R1, E1, Unit]
Like ZStream#into, but provides the result as a ZManaged to allow for scope composition.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f0: (A) => B): ZStream[R, E, B]
Returns a stream made of the elements of this stream transformed with
f0 - def mapAccum[S1, B](s1: S1)(f1: (S1, A) => (S1, B)): ZStream[R, E, B]
Statefully maps over the elements of this stream to produce new elements.
- final def mapAccumM[R1 <: R, E1 >: E, S1, B](s1: S1)(f1: (S1, A) => ZIO[R1, E1, (S1, B)]): ZStream[R1, E1, B]
Statefully and effectfully maps over the elements of this stream to produce new elements.
- final def mapConcat[B](f: (A) => Iterable[B]): ZStream[R, E, B]
Maps each element to an iterable, and flattens the iterables into the output of this stream.
- def mapConcatChunk[B](f: (A) => Chunk[B]): ZStream[R, E, B]
Maps each element to a chunk, and flattens the chunks into the output of this stream.
- final def mapConcatChunkM[R1 <: R, E1 >: E, B](f: (A) => ZIO[R1, E1, Chunk[B]]): ZStream[R1, E1, B]
Effectfully maps each element to a chunk, and flattens the chunks into the output of this stream.
- final def mapConcatM[R1 <: R, E1 >: E, B](f: (A) => ZIO[R1, E1, Iterable[B]]): ZStream[R1, E1, B]
Effectfully maps each element to an iterable, and flattens the iterables into the output of this stream.
- final def mapError[E1](f: (E) => E1): ZStream[R, E1, A]
Transforms the errors that possibly result from this stream.
- final def mapErrorCause[E1](f: (Cause[E]) => Cause[E1]): ZStream[R, E1, A]
Transforms the errors that possibly result from this stream.
- final def mapM[R1 <: R, E1 >: E, B](f: (A) => ZIO[R1, E1, B]): ZStream[R1, E1, B]
Maps over elements of the stream with the specified effectful function.
- final def mapMPar[R1 <: R, E1 >: E, B](n: Int)(f: (A) => ZIO[R1, E1, B]): ZStream[R1, E1, B]
Maps over elements of the stream with the specified effectful function, executing up to
ninvocations offconcurrently.Maps over elements of the stream with the specified effectful function, executing up to
ninvocations offconcurrently. Transformed elements will be emitted in the original order. - final def mapMParUnordered[R1 <: R, E1 >: E, B](n: Int)(f: (A) => ZIO[R1, E1, B]): ZStream[R1, E1, B]
Maps over elements of the stream with the specified effectful function, executing up to
ninvocations offconcurrently.Maps over elements of the stream with the specified effectful function, executing up to
ninvocations offconcurrently. The element order is not enforced by this combinator, and elements may be reordered. - final def merge[R1 <: R, E1 >: E, A1 >: A](that: ZStream[R1, E1, A1]): ZStream[R1, E1, A1]
Merges this stream and the specified stream together.
- final def mergeEither[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, Either[A, B]]
Merges this stream and the specified stream together to produce a stream of eithers.
- final def mergeWith[R1 <: R, E1 >: E, B, C](that: ZStream[R1, E1, B])(l: (A) => C, r: (B) => C): ZStream[R1, E1, C]
Merges this stream and the specified stream together to a common element type with the specified mapping functions.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def orElse[R1 <: R, E2, A1 >: A](that: => ZStream[R1, E2, A1]): ZStream[R1, E2, A1]
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.
- def partition(p: (A) => Boolean, buffer: Int = 16): ZManaged[R, E, (ZStream[R, E, A], ZStream[Any, E, A])]
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.
- final def partitionEither[B, C, R1 <: R, E1 >: E](p: (A) => ZIO[R1, E1, Either[B, C]], buffer: Int = 16): ZManaged[R1, E1, (ZStream[Any, E1, B], ZStream[Any, E1, C])]
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.
- final def peel[R1 <: R, E1 >: E, A1 >: A, B](sink: ZSink[R1, E1, A1, A1, B]): ZManaged[R1, E1, (B, ZStream[R1, E1, A1])]
Peels off enough material from the stream to construct an
Rusing the provided ZSink and then returns both theRand the remainder of the ZStream in a managed resource. - val process: ZManaged[R, E, Pull[R, E, A]]
processis a low-level consumption method, usually used for creating combinators and constructors.processis a low-level consumption method, usually used for creating combinators and constructors. For most usage, ZStream#fold, ZStream#foreach or ZStream#run should be preferred.The contract for the returned
Pullis as follows: - It must not be evaluted concurrently from multiple fibers - it is (usually) not thread-safe; - If an evaluation of thePullis interrupted, it is not safe to evaluate it again - it is (usually) not interruption-safe; - Once thePullhas failed with aNone, it is not safe to evaluate it again.The managed
Pullcan be used to read from the stream until it is empty (or possibly forever, if the stream is infinite). The providedPullis valid only inside the scope of the managed resource. - final def provide(r: R): Stream[E, A]
Provides the stream with its required environment, which eliminates its dependency on
R. - final def provideM[E1 >: E](r: ZIO[Any, E1, R]): Stream[E1, A]
An effectual version of
provide, useful when the act of provision requires an effect. - final def provideManaged[E1 >: E](m: Managed[E1, R]): Stream[E1, A]
Uses the given Managed to provide the environment required to run this stream, leaving no outstanding environments.
- final def provideSome[R0](env: (R0) => R): ZStream[R0, E, A]
Provides some of the environment required to run this effect, leaving the remainder
R0. - final def provideSomeM[R0, E1 >: E](env: ZIO[R0, E1, R]): ZStream[R0, E1, A]
Provides some of the environment required to run this effect, leaving the remainder
R0. - final def provideSomeManaged[R0, E1 >: E](env: ZManaged[R0, E1, R]): ZStream[R0, E1, A]
Uses the given ZManaged to provide some of the environment required to run this stream, leaving the remainder
R0. - final def repeat[R1 <: R, B, C](schedule: ZSchedule[R1, Unit, B]): ZStream[R1, E, A]
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.
- final def repeatEither[R1 <: R, B](schedule: ZSchedule[R1, Unit, B]): ZStream[R1, E, Either[B, A]]
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.
- final def repeatWith[R1 <: R, B, C](schedule: ZSchedule[R1, Unit, B])(f: (A) => C, g: (B) => C): ZStream[R1, 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.
- def run[R1 <: R, E1 >: E, A0, A1 >: A, B](sink: ZSink[R1, E1, A0, A1, B]): ZIO[R1, E1, B]
Runs the sink on the stream to produce either the sink's result or an error.
- final def runCollect: ZIO[R, E, List[A]]
Runs the stream and collects all of its elements in a list.
Runs the stream and collects all of its elements in a list.
Equivalent to
run(Sink.collectAll[A]). - final def runDrain: ZIO[R, E, Unit]
Runs the stream purely for its effects.
Runs the stream purely for its effects. Any elements emitted by the stream are discarded.
Equivalent to
run(Sink.drain). - final def schedule[R1 <: R, A1 >: A](schedule: ZSchedule[R1, A, Any]): ZStream[R1 with Clock, E, A1]
Schedules the output of the stream using the provided
scheduleand emits its output at the end (ifscheduleis finite). - final def scheduleEither[R1 <: R, E1 >: E, B](schedule: ZSchedule[R1, A, B]): ZStream[R1 with Clock, E1, Either[B, A]]
Schedules the output of the stream using the provided
scheduleand emits its output at the end (ifscheduleis finite). - final def scheduleElements[R1 <: R, A1 >: A](schedule: ZSchedule[R1, A, Any]): ZStream[R1 with Clock, E, A1]
Repeats each element of the stream using the provided
schedule, additionally emitting the schedule's output each time a schedule is completed.Repeats each element of the stream using the provided
schedule, additionally emitting the schedule's output each time a schedule is completed. Repeats are done in addition to the first execution, so thatscheduleElements(Schedule.once)means "emit element and if not short circuited, repeat element once". - final def scheduleElementsEither[R1 <: R, E1 >: E, B](schedule: ZSchedule[R1, A, B]): ZStream[R1 with Clock, E1, Either[B, A]]
Repeats each element of the stream using the provided
schedule, additionally emitting the schedule's output each time a schedule is completed.Repeats each element of the stream using the provided
schedule, additionally emitting the schedule's output each time a schedule is completed. Repeats are done in addition to the first execution, so thatscheduleElements(Schedule.once)means "emit element and if not short circuited, repeat element once". - final def scheduleElementsWith[R1 <: R, E1 >: E, B, C](schedule: ZSchedule[R1, A, B])(f: (A) => C, g: (B) => C): ZStream[R1 with Clock, E1, C]
Repeats each element of the stream using the provided schedule, additionally emitting the schedule's output each time a schedule is completed.
Repeats each element of the stream using the provided schedule, additionally emitting the schedule's output each time a schedule is completed. Repeats are done in addition to the first execution, so that
scheduleElements(Schedule.once)means "emit element and if not short circuited, repeat element once". Uses the provided functions to align the stream and schedule outputs on a common type. - final def scheduleWith[R1 <: R, E1 >: E, B, C](schedule: ZSchedule[R1, A, B])(f: (A) => C, g: (B) => C): ZStream[R1, E1, C]
Schedules the output of the stream using the provided
scheduleand emits its output at the end (ifscheduleis finite).Schedules the output of the stream using the provided
scheduleand emits its output at the end (ifscheduleis finite). Uses the provided function to align the stream and schedule outputs on the same type. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def take(n: Int): ZStream[R, E, A]
Takes the specified number of elements from this stream.
- def takeUntil(pred: (A) => Boolean): ZStream[R, E, A]
Takes all elements of the stream until the specified predicate evaluates to
true. - def takeWhile(pred: (A) => Boolean): ZStream[R, E, A]
Takes all elements of the stream for as long as the specified predicate evaluates to
true. - final def tap[R1 <: R, E1 >: E](f: (A) => ZIO[R1, E1, Any]): ZStream[R1, E1, A]
Adds an effect to consumption of every element of the stream.
- final def throttleEnforce(units: Long, duration: Duration, burst: Long = 0)(costFn: (A) => Long): ZStream[R with Clock, E, A]
Throttles elements of type A according to the given bandwidth parameters using the token bucket algorithm.
Throttles elements of type A 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 + burstthreshold. Elements that do not meet the bandwidth constraints are dropped. The weight of each element is determined by thecostFnfunction. - final def throttleEnforceM[R1 <: R, E1 >: E](units: Long, duration: Duration, burst: Long = 0)(costFn: (A) => ZIO[R1, E1, Long]): ZStream[R1 with Clock, E1, A]
Throttles elements of type A according to the given bandwidth parameters using the token bucket algorithm.
Throttles elements of type A 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 + burstthreshold. Elements that do not meet the bandwidth constraints are dropped. The weight of each element is determined by thecostFneffectful function. - final def throttleShape(units: Long, duration: Duration, burst: Long = 0)(costFn: (A) => Long): ZStream[R with Clock, E, A]
Delays elements of type A according to the given bandwidth parameters using the token bucket algorithm.
Delays elements of type A 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 + burstthreshold. The weight of each element is determined by thecostFnfunction. - final def throttleShapeM[R1 <: R, E1 >: E](units: Long, duration: Duration, burst: Long = 0)(costFn: (A) => ZIO[R1, E1, Long]): ZStream[R1 with Clock, E1, A]
Delays elements of type A according to the given bandwidth parameters using the token bucket algorithm.
Delays elements of type A 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 + burstthreshold. The weight of each element is determined by thecostFneffectful function. - final def timeout(d: Duration): ZStream[R with Clock, E, A]
Interrupts the stream if it does not produce a value after d duration.
- def toInputStream(implicit ev0: <:<[E, Throwable], ev1: <:<[A, Byte]): ZManaged[R, E, InputStream]
Converts this stream of bytes into a
java.io.InputStreamwrapped in a ZManaged.Converts this stream of bytes into a
java.io.InputStreamwrapped in a ZManaged. The returned input stream will only be valid within the scope of the ZManaged.- Annotations
- @silent("never used")
- final def toQueue[E1 >: E, A1 >: A](capacity: Int = 2): ZManaged[R, Nothing, Queue[Take[E1, A1]]]
Converts the stream to a managed queue.
Converts the stream to a managed queue. After the managed queue is used, the queue will never again produce values and should be discarded.
- final def toQueueUnbounded[E1 >: E, A1 >: A]: ZManaged[R, Nothing, Queue[Take[E1, A1]]]
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.
- def toString(): String
- Definition Classes
- AnyRef → Any
- def transduce[R1 <: R, E1 >: E, A1 >: A, C](sink: ZSink[R1, E1, A1, A1, C]): ZStream[R1, E1, C]
Applies a transducer to the stream, which converts one or more elements of type
Ainto elements of typeC. - final def transduceManaged[R1 <: R, E1 >: E, A1 >: A, B](managedSink: ZManaged[R1, E1, ZSink[R1, E1, A1, A1, B]]): ZStream[R1, E1, B]
Applies a transducer to the stream, converting elements of type
Ainto elements of typeC, with a managed resource of typeDavailable. - final def unNone[A1](implicit ev: <:<[A, Option[A1]]): ZStream[R, E, A1]
Filters any 'None'.
- final def unTake[E1 >: E, A1](implicit ev: <:<[A, Take[E1, A1]]): ZStream[R, E1, A1]
Filters any 'Take'.
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def zip[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, (A, B)]
Zips this stream together with the specified stream.
- final def zipLeft[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, A]
Runs this stream with the specified stream parallelly and keeps only values of this stream.
- final def zipRight[R1 <: R, E1 >: E, B](that: ZStream[R1, E1, B]): ZStream[R1, E1, B]
Runs this stream with the specified stream parallelly and keeps only values of specified stream.
- final def zipWith[R1 <: R, E1 >: E, B, C](that: ZStream[R1, E1, B])(f0: (Option[A], Option[B]) => Option[C]): ZStream[R1, E1, C]
Zips two streams together with a specified function.
- final def zipWithIndex: ZStream[R, E, (A, Int)]
Zips this stream together with the index of elements of the stream.
- final def zipWithLatest[R1 <: R, E1 >: E, B, C](that: ZStream[R1, E1, B])(f0: (A, B) => C): ZStream[R1, E1, C]
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.
Deprecated Value Members
- final def spaced[R1 <: R, A1 >: A](schedule: ZSchedule[R1, A, A1]): ZStream[R1 with Clock, E, A1]
- Annotations
- @deprecated
- Deprecated
(Since version 1.0.0) use scheduleElements
- final def spacedEither[R1 <: R, B](schedule: ZSchedule[R1, A, B]): ZStream[R1 with Clock, E, Either[B, A]]
Analogical to
spacedbut with distinction of stream elements and schedule output represented by EitherAnalogical to
spacedbut with distinction of stream elements and schedule output represented by Either- Annotations
- @deprecated
- Deprecated
(Since version 1.0.0) use scheduleElementsEither