The philosophy is that the FlowMaterializer has complete control over how it interprets the AST, no restrictions. Therefore it only involves one specified method: materialize() which returns a MaterializedFlow. Within the ActorBasedFlowMaterializer we materialize Sources and Sinks that implement the specified SimpleSource/SourceWithKey interfaces (same for Sinks), others are not supported. These traits are extensible and they require that an ActorBasedFlowMaterializer is passed into the factory methods. Other materializers can of course interpret these AST nodes differently, or they can use the actor-based facilities by creating a suitable materializer for them to use. This means that everything is fully extensible, but the infrastructure we provide concretely for ourselves is built exactly for that and nothing more. Overgeneralization would just lead nowhere. Also made FutureSink isActive and implement it using a light-weight Subscriber instead of a Flow/Transformer.
This commit is contained in:
parent
b7a509ec3e
commit
61b77ea50c
6 changed files with 592 additions and 437 deletions
|
|
@ -3,17 +3,9 @@
|
|||
*/
|
||||
package akka.stream.scaladsl2
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import org.reactivestreams.Publisher
|
||||
import akka.actor.ActorContext
|
||||
import akka.actor.ActorRefFactory
|
||||
import akka.actor.ActorSystem
|
||||
import akka.actor.ExtendedActorSystem
|
||||
import akka.actor.{ ActorContext, ActorRefFactory, ActorSystem, ExtendedActorSystem }
|
||||
import akka.stream.MaterializerSettings
|
||||
import akka.stream.impl2.ActorBasedFlowMaterializer
|
||||
import akka.stream.impl2.Ast
|
||||
import akka.stream.impl2.FlowNameCounter
|
||||
import akka.stream.impl2.StreamSupervisor
|
||||
import akka.stream.impl2.{ ActorBasedFlowMaterializer, Ast, FlowNameCounter, StreamSupervisor }
|
||||
|
||||
object FlowMaterializer {
|
||||
|
||||
|
|
@ -131,26 +123,25 @@ object FlowMaterializer {
|
|||
abstract class FlowMaterializer(val settings: MaterializerSettings) {
|
||||
|
||||
/**
|
||||
* The `namePrefix` is used as the first part of the names of the actors running
|
||||
* the processing steps.
|
||||
* The `namePrefix` shall be used for deriving the names of processing
|
||||
* entities that are created during materialization. This is meant to aid
|
||||
* logging and error reporting both during materialization and while the
|
||||
* stream is running.
|
||||
*/
|
||||
def withNamePrefix(name: String): FlowMaterializer
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
* ops are stored in reverse order
|
||||
* This method interprets the given Flow description and creates the running
|
||||
* stream. The result can be highly implementation specific, ranging from
|
||||
* local actor chains to remote-deployed processing networks.
|
||||
*/
|
||||
private[akka] def materialize[In, Out](source: Source[In], sink: Sink[Out], ops: List[Ast.AstNode]): MaterializedFlow
|
||||
|
||||
def materializeSource[In](source: IterableSource[In], flowName: String): Publisher[In]
|
||||
|
||||
def materializeSource[In](source: IteratorSource[In], flowName: String): Publisher[In]
|
||||
|
||||
def materializeSource[In](source: ThunkSource[In], flowName: String): Publisher[In]
|
||||
|
||||
def materializeSource[In](source: FutureSource[In], flowName: String): Publisher[In]
|
||||
|
||||
def materializeSource[In](source: TickSource[In], flowName: String): Publisher[In]
|
||||
def materialize[In, Out](source: Source[In], sink: Sink[Out], ops: List[Ast.AstNode]): MaterializedFlow
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This exception or subtypes thereof should be used to signal materialization
|
||||
* failures.
|
||||
*/
|
||||
class MaterializationException(msg: String, cause: Throwable = null) extends RuntimeException(msg, cause)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue