Accumulator

play.api.libs.streams.Accumulator
See theAccumulator companion object
sealed trait Accumulator[-E, +A]

An accumulator of elements into a future of a result.

This is essentially a lightweight wrapper around a Sink that gets materialised to a Future, but provides convenient methods for working directly with that future as well as transforming the input.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def asJava: Accumulator[E, A]

Convert this accumulator to a Java Accumulator.

Convert this accumulator to a Java Accumulator.

Attributes

Returns

The Java accumulator.

def map[B](f: A => B)(implicit executor: ExecutionContext): Accumulator[E, B]

Map the result of this accumulator to something else.

Map the result of this accumulator to something else.

Attributes

def mapFuture[B](f: A => Future[B])(implicit executor: ExecutionContext): Accumulator[E, B]

Map the result of this accumulator to a future of something else.

Map the result of this accumulator to a future of something else.

Attributes

def recover[B >: A](pf: PartialFunction[Throwable, B])(implicit executor: ExecutionContext): Accumulator[E, B]

Recover from errors encountered by this accumulator.

Recover from errors encountered by this accumulator.

Attributes

def recoverWith[B >: A](pf: PartialFunction[Throwable, Future[B]])(implicit executor: ExecutionContext): Accumulator[E, B]

Recover from errors encountered by this accumulator.

Recover from errors encountered by this accumulator.

Attributes

def run(source: Source[E, _])(implicit materializer: Materializer): Future[A]

Run this accumulator by feeding in the given source.

Run this accumulator by feeding in the given source.

Attributes

def run()(implicit materializer: Materializer): Future[A]

Run this accumulator by feeding nothing into it.

Run this accumulator by feeding nothing into it.

Attributes

def run(elem: E)(implicit materializer: Materializer): Future[A]

Run this accumulator by feeding a single element into it.

Run this accumulator by feeding a single element into it.

Attributes

def through[F](flow: Flow[F, E, _]): Accumulator[F, A]

Return a new accumulator that first feeds the input through the given flow before it goes through this accumulator.

Return a new accumulator that first feeds the input through the given flow before it goes through this accumulator.

Attributes

def toSink: Sink[E, Future[A]]

Convert this accumulator to a Sink that gets materialised to a Future.

Convert this accumulator to a Sink that gets materialised to a Future.

Attributes

Concrete methods

def ~>:[F](flow: Flow[F, E, _]): Accumulator[F, A]

Right associative operator alias for through.

Right associative operator alias for through.

This can be used for a more fluent DSL that matches the flow of the data, for example:

 val intAccumulator: Accumulator[Int, Unit] = ...
 val toInt = Flow[String].map(_.toInt)
 val stringAccumulator = toInt ~>: intAccumulator

Attributes

def ~>:(source: Source[E, _])(implicit materializer: Materializer): Future[A]

Right associative operator alias for run.

Right associative operator alias for run.

This can be used for a more fluent DSL that matches the flow of the data, for example:

 val intAccumulator: Accumulator[Int, Int] = ...
 val source = Source(1 to 3)
 val intFuture = source ~>: intAccumulator

Attributes