2014-09-03 21:54:18 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2014 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.stream.scaladsl2
|
|
|
|
|
|
2014-10-02 17:32:08 +02:00
|
|
|
import org.reactivestreams.Subscriber
|
2014-09-01 13:30:15 +02:00
|
|
|
|
2014-10-08 15:15:46 +02:00
|
|
|
import scala.concurrent.Future
|
2014-10-02 17:32:08 +02:00
|
|
|
import scala.language.implicitConversions
|
2014-09-03 21:54:18 +02:00
|
|
|
import scala.annotation.unchecked.uncheckedVariance
|
|
|
|
|
|
|
|
|
|
/**
|
2014-10-02 17:32:08 +02:00
|
|
|
* A `Sink` is a set of stream processing steps that has one open input and an attached output.
|
|
|
|
|
* Can be used as a `Subscriber`
|
2014-09-03 21:54:18 +02:00
|
|
|
*/
|
2014-10-02 17:32:08 +02:00
|
|
|
trait Sink[-In] {
|
2014-10-02 13:34:27 +02:00
|
|
|
/**
|
|
|
|
|
* Connect this `Sink` to a `Tap` and run it. The returned value is the materialized value
|
|
|
|
|
* of the `Tap`, e.g. the `Subscriber` of a [[SubscriberTap]].
|
|
|
|
|
*/
|
|
|
|
|
def runWith(tap: TapWithKey[In])(implicit materializer: FlowMaterializer): tap.MaterializedType
|
2014-09-03 21:54:18 +02:00
|
|
|
}
|
2014-10-08 15:15:46 +02:00
|
|
|
|
|
|
|
|
object Sink {
|
|
|
|
|
/**
|
|
|
|
|
* Helper to create [[Sink]] from `Subscriber`.
|
|
|
|
|
*/
|
|
|
|
|
def apply[T](subscriber: Subscriber[T]): Drain[T] = SubscriberDrain(subscriber)
|
|
|
|
|
}
|