object Source

Java API

Source
Source.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Source
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def actorPublisher[T](props: Props): Source[T, ActorRef]

    Creates a Source that is materialized to an akka.actor.ActorRef which points to an Actor created according to the passed in akka.actor.Props.

    Creates a Source that is materialized to an akka.actor.ActorRef which points to an Actor created according to the passed in akka.actor.Props. Actor created by the props should be akka.stream.actor.ActorPublisher.

  5. def actorRef[T](bufferSize: Int, overflowStrategy: OverflowStrategy): Source[T, ActorRef]

    Creates a Source that is materialized as an akka.actor.ActorRef.

    Creates a Source that is materialized as an akka.actor.ActorRef. Messages sent to this actor will be emitted to the stream if there is demand from downstream, otherwise they will be buffered until request for demand is received.

    Depending on the defined akka.stream.OverflowStrategy it might drop elements if there is no space available in the buffer.

    The strategy akka.stream.OverflowStrategy.backpressure is not supported, and an IllegalArgument("Backpressure overflowStrategy not supported") will be thrown if it is passed as argument.

    The buffer can be disabled by using bufferSize of 0 and then received messages are dropped if there is no demand from downstream. When bufferSize is 0 the overflowStrategy does not matter. An async boundary is added after this Source; as such, it is never safe to assume the downstream will always generate demand.

    The stream can be completed successfully by sending the actor reference a akka.actor.Status.Success (whose content will be ignored) in which case already buffered elements will be signaled before signaling completion, or by sending akka.actor.PoisonPill in which case completion will be signaled immediately.

    The stream can be completed with failure by sending a akka.actor.Status.Failure to the actor reference. In case the Actor is still draining its internal buffer (after having received a akka.actor.Status.Success) before signaling completion and it receives a akka.actor.Status.Failure, the failure will be signaled downstream immediately (instead of the completion signal).

    The actor will be stopped when the stream is completed, failed or canceled from downstream, i.e. you can watch it to get notified when that happens.

    See also akka.stream.javadsl.Source.queue.

    bufferSize

    The size of the buffer in element count

    overflowStrategy

    Strategy that is used when incoming elements cannot fit inside the buffer

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def asSubscriber[T](): Source[T, Subscriber[T]]

    Creates a Source that is materialized as a org.reactivestreams.Subscriber

  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def combine[T, U](first: Source[T, _], second: Source[T, _], rest: List[Source[T, _]], strategy: Function[Integer, _ <: Graph[UniformFanInShape[T, U], NotUsed]]): Source[U, NotUsed]

    Combines several sources with fan-in strategy like Merge or Concat and returns Source.

  10. def cycle[O](f: Creator[Iterator[O]]): Source[O, NotUsed]

    Helper to create 'cycled' Source from iterator provider.

    Helper to create 'cycled' Source from iterator provider. Example usage:

    Source.cycle(() -> Arrays.asList(1, 2, 3).iterator());

    Start a new 'cycled' Source from the given elements. The producer stream of elements will continue infinitely by repeating the sequence of elements provided by function parameter.

  11. def empty[O](): Source[O, NotUsed]

    Create a Source with no elements, i.e.

    Create a Source with no elements, i.e. an empty stream that is completed immediately for every connected Sink.

  12. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  14. def failed[T](cause: Throwable): Source[T, NotUsed]

    Create a Source that immediately ends the stream with the cause failure to every connected Sink.

  15. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def from[O](iterable: Iterable[O]): Source[O, NotUsed]

    Helper to create Source from Iterable.

    Helper to create Source from Iterable. Example usage:

    List<Integer> data = new ArrayList<Integer>();
    data.add(1);
    data.add(2);
    data.add(3);
    Source.from(data);

    Starts a new Source from the given Iterable. This is like starting from an Iterator, but every Subscriber directly attached to the Publisher of this stream will see an individual flow of elements (always starting from the beginning) regardless of when they subscribed.

    Make sure that the Iterable is immutable or at least not modified after being used as a Source. Otherwise the stream may fail with ConcurrentModificationException or other more subtle errors may occur.

  17. def fromCompletionStage[O](future: CompletionStage[O]): Source[O, NotUsed]

    Start a new Source from the given CompletionStage.

    Start a new Source from the given CompletionStage. The stream will consist of one element when the CompletionStage is completed with a successful value, which may happen before or after materializing the Flow. The stream terminates with a failure if the CompletionStage is completed with a failure.

  18. def fromFuture[O](future: Future[O]): Source[O, NotUsed]

    Start a new Source from the given Future.

    Start a new Source from the given Future. The stream will consist of one element when the Future is completed with a successful value, which may happen before or after materializing the Flow. The stream terminates with a failure if the Future is completed with a failure.

  19. def fromGraph[T, M](g: Graph[SourceShape[T], M]): Source[T, M]

    A graph with the shape of a source logically is a source, this method makes it so also in type.

  20. def fromIterator[O](f: Creator[Iterator[O]]): Source[O, NotUsed]

    Helper to create Source from Iterator.

    Helper to create Source from Iterator. Example usage:

    List<Integer> data = new ArrayList<Integer>();
    data.add(1);
    data.add(2);
    data.add(3);
    Source.from(() -> data.iterator());

    Start a new Source from the given Iterator. The produced stream of elements will continue until the iterator runs empty or fails during evaluation of the next() method. Elements are pulled out of the iterator in accordance with the demand coming from the downstream transformation steps.

  21. def fromPublisher[O](publisher: Publisher[O]): Source[O, NotUsed]

    Helper to create Source from Publisher.

    Helper to create Source from Publisher.

    Construct a transformation starting with given publisher. The transformation steps are executed by a series of org.reactivestreams.Processor instances that mediate the flow of elements downstream and the propagation of back-pressure upstream.

  22. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def lazily[T, M](create: Creator[Source[T, M]]): Source[T, CompletionStage[M]]

    Creates a Source that is not materialized until there is downstream demand, when the source gets materialized the materialized future is completed with its value, if downstream cancels or fails without any demand the create factory is never called and the materialized CompletionStage is failed.

  26. def maybe[T]: Source[T, CompletableFuture[Optional[T]]]

    Create a Source which materializes a java.util.concurrent.CompletableFuture which controls what element will be emitted by the Source.

    Create a Source which materializes a java.util.concurrent.CompletableFuture which controls what element will be emitted by the Source. If the materialized promise is completed with a filled Optional, that value will be produced downstream, followed by completion. If the materialized promise is completed with an empty Optional, no value will be produced downstream and completion will be signalled immediately. If the materialized promise is completed with a failure, then the returned source will terminate with that error. If the downstream of this source cancels before the promise has been completed, then the promise will be completed with an empty Optional.

  27. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. final def notify(): Unit
    Definition Classes
    AnyRef
  29. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  30. def queue[T](bufferSize: Int, overflowStrategy: OverflowStrategy): Source[T, SourceQueueWithComplete[T]]

    Creates a Source that is materialized as an akka.stream.javadsl.SourceQueue.

    Creates a Source that is materialized as an akka.stream.javadsl.SourceQueue. You can push elements to the queue and they will be emitted to the stream if there is demand from downstream, otherwise they will be buffered until request for demand is received. Elements in the buffer will be discarded if downstream is terminated.

    Depending on the defined akka.stream.OverflowStrategy it might drop elements if there is no space available in the buffer.

    Acknowledgement mechanism is available. akka.stream.javadsl.SourceQueue.offer returns CompletionStage<QueueOfferResult> which completes with QueueOfferResult.enqueued if element was added to buffer or sent downstream. It completes with QueueOfferResult.dropped if element was dropped. Can also complete with QueueOfferResult.Failure - when stream failed or QueueOfferResult.QueueClosed when downstream is completed.

    The strategy akka.stream.OverflowStrategy.backpressure will not complete last offer():CompletionStage call when buffer is full.

    You can watch accessibility of stream with akka.stream.javadsl.SourceQueue.watchCompletion. It returns future that completes with success when stream is completed or fail when stream is failed.

    The buffer can be disabled by using bufferSize of 0 and then received message will wait for downstream demand unless there is another message waiting for downstream demand, in that case offer result will be completed according to the overflow strategy.

    SourceQueue that current source is materialized to is for single thread usage only.

    bufferSize

    size of buffer in element count

    overflowStrategy

    Strategy that is used when incoming elements cannot fit inside the buffer

  31. def range(start: Int, end: Int, step: Int): Source[Integer, NotUsed]

    Creates Source that represents integer values in range [start;end], with the given step.

    Creates Source that represents integer values in range [start;end], with the given step. It allows to create Source out of range as simply as on Scala Source(1 to N)

    Uses Int, Int) internally

    See also

    Int, Int)

  32. def range(start: Int, end: Int): Source[Integer, NotUsed]

    Creates Source that represents integer values in range [start;end], step equals to 1.

    Creates Source that represents integer values in range [start;end], step equals to 1. It allows to create Source out of range as simply as on Scala Source(1 to N)

    Uses Int) internally

    See also

    Int)

  33. def repeat[T](element: T): Source[T, NotUsed]

    Create a Source that will continually emit the given element.

  34. def single[T](element: T): Source[T, NotUsed]

    Create a Source with one element.

    Create a Source with one element. Every connected Sink of this stream will see an individual stream consisting of one element.

  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def tick[O](initialDelay: FiniteDuration, interval: FiniteDuration, tick: O): Source[O, Cancellable]

    Elements are emitted periodically with the specified interval.

    Elements are emitted periodically with the specified interval. The tick element will be delivered to downstream consumers that has requested any elements. If a consumer has not requested any elements at the point in time when the tick element is produced it will not receive that tick element later. It will receive new tick elements as soon as it has requested more elements.

  37. def toString(): String
    Definition Classes
    AnyRef → Any
  38. def unfold[S, E](s: S, f: Function[S, Optional[Pair[S, E]]]): Source[E, NotUsed]

    Create a Source that will unfold a value of type S into a pair of the next state S and output elements of type E.

  39. def unfoldAsync[S, E](s: S, f: Function[S, CompletionStage[Optional[Pair[S, E]]]]): Source[E, NotUsed]

    Same as unfold, but uses an async function to generate the next state-element tuple.

  40. def unfoldResource[T, S](create: Creator[S], read: Function[S, Optional[T]], close: Procedure[S]): Source[T, NotUsed]

    Start a new Source from some resource which can be opened, read and closed.

    Start a new Source from some resource which can be opened, read and closed. Interaction with resource happens in a blocking way.

    Example:

    Source.unfoldResource(
      () -> new BufferedReader(new FileReader("...")),
      reader -> reader.readLine(),
      reader -> reader.close())

    You can use the supervision strategy to handle exceptions for read function. All exceptions thrown by create or close will fail the stream.

    Restart supervision strategy will close and create blocking IO again. Default strategy is Stop which means that stream will be terminated on error in read function by default.

    You can configure the default dispatcher for this Source by changing the akka.stream.blocking-io-dispatcher or set it for a given Source by using ActorAttributes.

    create

    - function that is called on stream start and creates/opens resource.

    read

    - function that reads data from opened resource. It is called each time backpressure signal is received. Stream calls close and completes when read returns None.

    close

    - function that closes resource

  41. def unfoldResourceAsync[T, S](create: Creator[CompletionStage[S]], read: Function[S, CompletionStage[Optional[T]]], close: Function[S, CompletionStage[Done]]): Source[T, NotUsed]

    Start a new Source from some resource which can be opened, read and closed.

    Start a new Source from some resource which can be opened, read and closed. It's similar to unfoldResource but takes functions that return CompletionStage instead of plain values.

    You can use the supervision strategy to handle exceptions for read function or failures of produced Futures. All exceptions thrown by create or close as well as fails of returned futures will fail the stream.

    Restart supervision strategy will close and create resource. Default strategy is Stop which means that stream will be terminated on error in read function (or future) by default.

    You can configure the default dispatcher for this Source by changing the akka.stream.blocking-io-dispatcher or set it for a given Source by using ActorAttributes.

    create

    - function that is called on stream start and creates/opens resource.

    read

    - function that reads data from opened resource. It is called each time backpressure signal is received. Stream calls close and completes when CompletionStage from read function returns None.

    close

    - function that closes resource

  42. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. def zipN[T](sources: List[Source[T, _]]): Source[List[T], NotUsed]

    Combine the elements of multiple streams into a stream of lists.

  46. def zipWithN[T, O](zipper: Function[List[T], O], sources: List[Source[T, _]]): Source[O, NotUsed]

Inherited from AnyRef

Inherited from Any

Ungrouped