Object/Class

akka.stream.scaladsl

Source

Related Docs: class Source | package scaladsl

Permalink

object Source

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def actorPublisher[T](props: Props): Source[T, ActorRef]

    Permalink

    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 must be akka.stream.actor.ActorPublisher.

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

    Permalink

    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.

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

    The stream can be completed with failure by sending akka.actor.Status.Failure to the actor reference. In case the Actor is still draining its internal buffer (after having received an 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.

    bufferSize

    The size of the buffer in element count

    overflowStrategy

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

  6. def apply[T](iterable: Iterable[T]): Source[T, NotUsed]

    Permalink

    Helper to create Source from Iterable.

    Helper to create Source from Iterable. Example usage: Source(Seq(1,2,3))

    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.

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def asSubscriber[T]: Source[T, Subscriber[T]]

    Permalink

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

  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. def combine[T, U](first: Source[T, _], second: Source[T, _], rest: Source[T, _]*)(strategy: (Int) ⇒ Graph[UniformFanInShape[T, U], NotUsed]): Source[U, NotUsed]

    Permalink

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

  11. def empty[T]: Source[T, NotUsed]

    Permalink

    A Source with no elements, i.e.

    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

    Permalink
    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def failed[T](cause: Throwable): Source[T, NotUsed]

    Permalink

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

  15. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def fromCompletionStage[T](future: CompletionStage[T]): Source[T, NotUsed]

    Permalink

    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.

  17. def fromFuture[T](future: Future[T]): Source[T, NotUsed]

    Permalink

    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.

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

    Permalink

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

  19. def fromIterator[T](f: () ⇒ Iterator[T]): Source[T, NotUsed]

    Permalink

    Helper to create Source from Iterator.

    Helper to create Source from Iterator. Example usage: Source.fromIterator(() => Iterator.from(0))

    Start a new Source from the given function that produces anIterator. 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.

  20. def fromPublisher[T](publisher: Publisher[T]): Source[T, NotUsed]

    Permalink

    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.

  21. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  23. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  24. def maybe[T]: Source[T, Promise[Option[T]]]

    Permalink

    Create a Source which materializes a scala.concurrent.Promise which controls what element will be emitted by the Source.

    Create a Source which materializes a scala.concurrent.Promise which controls what element will be emitted by the Source. If the materialized promise is completed with a Some, that value will be produced downstream, followed by completion. If the materialized promise is completed with a None, 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 None.

  25. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. def queue[T](bufferSize: Int, overflowStrategy: OverflowStrategy): Source[T, SourceQueueWithComplete[T]]

    Permalink

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

    Creates a Source that is materialized as an akka.stream.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.SourceQueue.offer returns Future[StreamCallbackStatus[Boolean]] which completes with Success(true) if element was added to buffer or sent downstream. It completes with Success(false) if element was dropped. Can also complete with akka.stream.StreamCallbackStatus.Failure - when stream failed or akka.stream.StreamCallbackStatus.StreamCompleted when downstream is completed.

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

    You can watch accessibility of stream with akka.stream.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. When bufferSize is 0 the overflowStrategy does not matter.

    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

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

    Permalink

    Create a Source that will continually emit the given element.

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

    Permalink

    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.

  31. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  32. def tick[T](initialDelay: FiniteDuration, interval: FiniteDuration, tick: T): Source[T, Cancellable]

    Permalink

    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.

  33. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  34. def unfold[S, E](s: S)(f: (S) ⇒ Option[(S, E)]): Source[E, NotUsed]

    Permalink

    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.

    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.

    For example, all the Fibonacci numbers under 10M:

    Source.unfold(01) {
     case (a, _) if a > 10000000None
     case (a, b) ⇒ Some((b → (a + b)) → a)
    }
  35. def unfoldAsync[S, E](s: S)(f: (S) ⇒ Future[Option[(S, E)]]): Source[E, NotUsed]

    Permalink

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

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

    async fibonacci example:

    Source.unfoldAsync(01) {
     case (a, _) if a > 10000000 ⇒ Future.successful(None)
     case (a, b) ⇒ Future{
       Thread.sleep(1000)
       Some((b → (a + b)) → a)
     }
    }
  36. def unfoldResource[T, S](create: () ⇒ S, read: (S) ⇒ Option[T], close: (S) ⇒ Unit): Source[T, NotUsed]

    Permalink

    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 => Option(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

  37. def unfoldResourceAsync[T, S](create: () ⇒ Future[S], read: (S) ⇒ Future[Option[T]], close: (S) ⇒ Future[Done]): Source[T, NotUsed]

    Permalink

    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 Futures 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 Future from read function returns None.

    close

    - function that closes resource

  38. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped