Flow

ox.flow.Flow
See theFlow companion class

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Show all
Self type
Flow.type

Members list

Value members

Inherited methods

def concat[T](flows: Seq[Flow[T]]): Flow[T]

Creates a flow which concatenates the given flows in order. First elements from the first flow are emitted, then from the second etc. If any of the flows completes with an error, it is propagated.

Creates a flow which concatenates the given flows in order. First elements from the first flow are emitted, then from the second etc. If any of the flows completes with an error, it is propagated.

Attributes

Inherited from:
FlowCompanionOps
def empty[T]: Flow[T]

Creates an empty flow, which emits no elements and completes immediately.

Creates an empty flow, which emits no elements and completes immediately.

Attributes

Inherited from:
FlowCompanionOps
def failed[T](t: Throwable): Flow[T]

Creates a flow that fails immediately with the given java.lang.Throwable

Creates a flow that fails immediately with the given java.lang.Throwable

Value parameters

t

The java.lang.Throwable to fail with

Attributes

Inherited from:
FlowCompanionOps
def fromFile(path: Path, chunkSize: Int): Flow[Chunk[Byte]]

Creates a flow that emits byte chunks read from a file.

Creates a flow that emits byte chunks read from a file.

Value parameters

chunkSize

maximum number of bytes to read from the file before emitting a new chunk.

path

path the file to read from.

Attributes

Inherited from:
FlowCompanionIOOps
def fromFork[T](f: Fork[T]): Flow[T]

Creates a flow from the given fork. The flow will emit up to one element, or complete by throwing an exception if the fork fails.

Creates a flow from the given fork. The flow will emit up to one element, or complete by throwing an exception if the fork fails.

Attributes

Inherited from:
FlowCompanionOps
def fromFuture[T](from: Future[T]): Flow[T]

Creates a flow that emits a single element when from completes, or throws an exception when from fails.

Creates a flow that emits a single element when from completes, or throws an exception when from fails.

Attributes

Inherited from:
FlowCompanionOps
def fromFutureSource[T](from: Future[Source[T]]): Flow[T]

Creates a flow that emits all elements from the given future Source when from completes.

Creates a flow that emits all elements from the given future Source when from completes.

Attributes

Inherited from:
FlowCompanionOps
def fromInputStream(is: InputStream, chunkSize: Int): Flow[Chunk[Byte]]

Converts a java.io.InputStream into a Flow[Chunk[Bytes]].

Converts a java.io.InputStream into a Flow[Chunk[Bytes]].

Value parameters

chunkSize

maximum number of bytes to read from the underlying InputStream before emitting a new chunk.

is

an InputStream to read bytes from.

Attributes

Inherited from:
FlowCompanionIOOps
def fromIterable[T](it: Iterable[T]): Flow[T]

Creates a flow from the given iterable. Each element of the iterable is emitted in order.

Creates a flow from the given iterable. Each element of the iterable is emitted in order.

Attributes

Inherited from:
FlowCompanionOps
def fromIterator[T](it: => Iterator[T]): Flow[T]

Creates a flow from the given (lazily evaluated) iterator. Each element of the iterator is emitted in order.

Creates a flow from the given (lazily evaluated) iterator. Each element of the iterator is emitted in order.

Attributes

Inherited from:
FlowCompanionOps
def fromPublisher[T](p: Publisher[T])(using BufferCapacity): Flow[T]

Creates a Flow from a Publisher, that is, which emits the elements received by subscribing to the publisher. A new subscription is created every time this flow is run.

Creates a Flow from a Publisher, that is, which emits the elements received by subscribing to the publisher. A new subscription is created every time this flow is run.

The data is passed from a subscription to the flow using a ox.channel.Channel, with a capacity given by the BufferCapacity in scope. That's also how many elements will be at most requested from the publisher at a time.

The publisher parameter should implement the JDK 9+ Flow.Publisher API. To create a flow from a publisher implementing com.reactivestreams.Publisher, use the flow-reactive-streams module.

Attributes

Inherited from:
FlowCompanionReactiveOps
def fromSource[T](source: Source[T]): Flow[T]

Creates a flow using the given source. An element is emitted for each value received from the source. If the source is completed with an error, is it propagated by throwing.

Creates a flow using the given source. An element is emitted for each value received from the source. If the source is completed with an error, is it propagated by throwing.

Attributes

Inherited from:
FlowCompanionOps
def fromValues[T](ts: T*): Flow[T]

Creates a flow from the given values. Each value is emitted in order.

Creates a flow from the given values. Each value is emitted in order.

Attributes

Inherited from:
FlowCompanionOps
def interleaveAll[T](flows: Seq[Flow[T]], segmentSize: Int, eagerComplete: Boolean)(using BufferCapacity): Flow[T]

Sends a given number of elements (determined byc segmentSize) from each flow in flows to the returned flow and repeats. The order of elements in all flows is preserved.

Sends a given number of elements (determined byc segmentSize) from each flow in flows to the returned flow and repeats. The order of elements in all flows is preserved.

If any of the flows is done before the others, the behavior depends on the eagerCancel flag. When set to true, the returned flow is completed immediately, otherwise the interleaving continues with the remaining non-completed flows. Once all but one flows are complete, the elements of the remaining non-complete flow are emitted by the returned flow.

The provided flows are run concurrently and asynchronously.

Value parameters

eagerComplete

If true, the returned flow is completed as soon as any of the flows completes. If false, the interleaving continues with the remaining non-completed flows.

flows

The flows whose elements will be interleaved.

segmentSize

The number of elements sent from each flow before switching to the next one. Default is 1.

Attributes

Inherited from:
FlowCompanionOps
def iterate[T](zero: T)(f: T => T): Flow[T]

Creates a flow which emits elements starting with zero, and then applying f to the previous element to get the next one.

Creates a flow which emits elements starting with zero, and then applying f to the previous element to get the next one.

Attributes

Inherited from:
FlowCompanionOps
def range(from: Int, to: Int, step: Int): Flow[Int]

Creates a flow which emits a range of numbers, from from, to to (inclusive), stepped by step.

Creates a flow which emits a range of numbers, from from, to to (inclusive), stepped by step.

Attributes

Inherited from:
FlowCompanionOps
def repeat[T](element: T): Flow[T]

Creates a flow, which emits the given element repeatedly.

Creates a flow, which emits the given element repeatedly.

Attributes

Inherited from:
FlowCompanionOps
def repeatEval[T](f: => T): Flow[T]

Creates a flow, which emits the result of evaluating f repeatedly. As the parameter is passed by-name, the evaluation is deferred until the element is emitted, and happens multiple times.

Creates a flow, which emits the result of evaluating f repeatedly. As the parameter is passed by-name, the evaluation is deferred until the element is emitted, and happens multiple times.

Value parameters

f

The code block, computing the element to emit.

Attributes

Inherited from:
FlowCompanionOps
def repeatEvalWhileDefined[T](f: => Option[T]): Flow[T]

Creates a flow, which emits the value contained in the result of evaluating f repeatedly. When the evaluation of f returns a None, the flow is completed as "done", and no more values are evaluated or emitted.

Creates a flow, which emits the value contained in the result of evaluating f repeatedly. When the evaluation of f returns a None, the flow is completed as "done", and no more values are evaluated or emitted.

As the f parameter is passed by-name, the evaluation is deferred until the element is emitted, and happens multiple times.

Value parameters

f

The code block, computing the optional element to emit.

Attributes

Inherited from:
FlowCompanionOps
def tick[T](interval: FiniteDuration, value: T): Flow[T]

Creates a flow which emits the given value repeatedly, at least interval apart between each two elements. The first value is emitted immediately.

Creates a flow which emits the given value repeatedly, at least interval apart between each two elements. The first value is emitted immediately.

The interval is measured between subsequent emissions. Hence, if the following transformation pipeline is slow, the next emission can occur immediately after the previous one is fully processed (if processing took more than the inter-emission interval duration). However, ticks do not accumulate; for example, if processing is slow enough that multiple intervals pass between send invocations, only one tick will be sent.

Value parameters

interval

The temporal spacing between subsequent ticks.

value

The element to emitted on every tick.

Attributes

Inherited from:
FlowCompanionOps
def timeout[T](timeout: FiniteDuration): Flow[T]

Create a flow which sleeps for the given timeout and then completes as done.

Create a flow which sleeps for the given timeout and then completes as done.

Attributes

Inherited from:
FlowCompanionOps
def unfold[S, T](initial: S)(f: S => Option[(T, S)]): Flow[T]

Creates a flow which emits the first element of tuples returned by repeated applications of f. The initial state is used for the first application, and then the state is updated with the second element of the tuple. Emission stops when f returns None, otherwise it continues indefinitely.

Creates a flow which emits the first element of tuples returned by repeated applications of f. The initial state is used for the first application, and then the state is updated with the second element of the tuple. Emission stops when f returns None, otherwise it continues indefinitely.

Attributes

Inherited from:
FlowCompanionOps
def usingEmit[T](withEmit: (FlowEmit[T]) => Unit): Flow[T]

Creates a flow, which when run, provides a FlowEmit instance to the given withEmit function. Elements can be emitted to be processed by downstream stages by calling FlowEmit.apply.

Creates a flow, which when run, provides a FlowEmit instance to the given withEmit function. Elements can be emitted to be processed by downstream stages by calling FlowEmit.apply.

The FlowEmit instance provided to the withEmit callback should only be used on the calling thread. That is, FlowEmit is thread-unsafe. Moreover, the instance should not be stored or captured in closures, which outlive the invocation of withEmit.

Attributes

Inherited from:
FlowCompanionOps