move Typed ActorMaterializer to scaladsl/javadsl, #24868
* add type alias for typed ActorMaterializer * name it ActorMaterializerFactory in javadsl Migration guide: Scala: import akka.stream.typed.ActorMaterializer -> akka.stream.typed.scaladsl.ActorMaterializer Java: import akka.stream.typed.ActorMaterializer -> akka.stream.typed.javadsl.ActorMaterializerFactory
This commit is contained in:
parent
989a80d90f
commit
52f24e5174
10 changed files with 55 additions and 31 deletions
|
|
@ -14,7 +14,8 @@ To use Akka Streams Typed, add the module to your project:
|
|||
|
||||
@ref:[Akka Streams](../stream/index.md) make it easy to model type-safe message processing pipelines. With typed actors it is possible to connect streams to actors without loosing the type information.
|
||||
|
||||
This module contains typed alternatives to the @ref:[already existing `ActorRef` sources and sinks](../stream/stream-integrations.md) together with a factory methods for @scala[@scaladoc[`ActorMaterializer`](akka.stream.typed.ActorMaterializer)]@java[@javadoc[`ActorMaterializer`](akka.stream.typed.ActorMaterializer)] which takes a typed `ActorSystem`.
|
||||
This module contains typed alternatives to the @ref:[already existing `ActorRef` sources and sinks](../stream/stream-integrations.md) together with a factory methods for
|
||||
@scala[@scaladoc[`ActorMaterializer`](akka.stream.typed.scaladsl.ActorMaterializer)]@java[@javadoc[`ActorMaterializerFactory`](akka.stream.typed.javadsl.ActorMaterializerFactory)] which takes a typed `ActorSystem`.
|
||||
|
||||
The materializer created from these factory methods and sources together with sinks contained in this module can be mixed and matched with the original Akka Streams building blocks from the original module.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,31 +2,16 @@
|
|||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.stream.typed
|
||||
package akka.stream.typed.javadsl
|
||||
|
||||
import akka.actor.typed.ActorSystem
|
||||
import akka.stream.ActorMaterializerSettings
|
||||
|
||||
object ActorMaterializer {
|
||||
object ActorMaterializerFactory {
|
||||
import akka.actor.typed.scaladsl.adapter._
|
||||
|
||||
/**
|
||||
* Scala API: Creates an ActorMaterializer which will execute every step of a transformation
|
||||
* pipeline within its own [[akka.actor.Actor]]. The required [[akka.actor.typed.ActorSystem]]
|
||||
* will be used to create one actor that in turn creates actors for the transformation steps.
|
||||
*
|
||||
* The materializer's [[akka.stream.ActorMaterializerSettings]] will be obtained from the
|
||||
* configuration of the `context`'s underlying [[akka.actor.typed.ActorSystem]].
|
||||
*
|
||||
* The `namePrefix` is used as the first part of the names of the actors running
|
||||
* the processing steps. The default `namePrefix` is `"flow"`. The actor names are built up of
|
||||
* `namePrefix-flowNumber-flowStepNumber-stepName`.
|
||||
*/
|
||||
def apply[T](materializerSettings: Option[ActorMaterializerSettings] = None, namePrefix: Option[String] = None)(implicit actorSystem: ActorSystem[T]): akka.stream.ActorMaterializer =
|
||||
akka.stream.ActorMaterializer(materializerSettings, namePrefix)(actorSystem.toUntyped)
|
||||
|
||||
/**
|
||||
* Java API: Creates an ActorMaterializer which will execute every step of a transformation
|
||||
* Creates an `ActorMaterializer` which will execute every step of a transformation
|
||||
* pipeline within its own [[akka.actor.Actor]]. The required [[akka.actor.typed.ActorSystem]]
|
||||
* will be used to create these actors, therefore it is *forbidden* to pass this object
|
||||
* to another actor if the factory is an ActorContext.
|
||||
|
|
@ -35,18 +20,18 @@ object ActorMaterializer {
|
|||
* The actor names are built up of `namePrefix-flowNumber-flowStepNumber-stepName`.
|
||||
*/
|
||||
def create[T](actorSystem: ActorSystem[T]): akka.stream.ActorMaterializer =
|
||||
apply()(actorSystem)
|
||||
akka.stream.ActorMaterializer.create(actorSystem.toUntyped)
|
||||
|
||||
/**
|
||||
* Java API: Creates an ActorMaterializer which will execute every step of a transformation
|
||||
* Creates an `ActorMaterializer` which will execute every step of a transformation
|
||||
* pipeline within its own [[akka.actor.Actor]]. The required [[akka.actor.typed.ActorSystem]]
|
||||
* will be used to create one actor that in turn creates actors for the transformation steps.
|
||||
*/
|
||||
def create[T](settings: ActorMaterializerSettings, actorSystem: ActorSystem[T]): akka.stream.ActorMaterializer =
|
||||
apply(Option(settings), None)(actorSystem)
|
||||
akka.stream.ActorMaterializer.create(settings, actorSystem.toUntyped)
|
||||
|
||||
/**
|
||||
* Java API: Creates an ActorMaterializer which will execute every step of a transformation
|
||||
* Creates an `ActorMaterializer` which will execute every step of a transformation
|
||||
* pipeline within its own [[akka.actor.Actor]]. The required [[akka.actor.typed.ActorSystem]]
|
||||
* will be used to create these actors, therefore it is *forbidden* to pass this object
|
||||
* to another actor if the factory is an ActorContext.
|
||||
|
|
@ -56,6 +41,6 @@ object ActorMaterializer {
|
|||
* `namePrefix-flowNumber-flowStepNumber-stepName`.
|
||||
*/
|
||||
def create[T](settings: ActorMaterializerSettings, namePrefix: String, actorSystem: ActorSystem[T]): akka.stream.ActorMaterializer =
|
||||
apply(Option(settings), Option(namePrefix))(actorSystem)
|
||||
akka.stream.ActorMaterializer.create(settings, actorSystem.toUntyped, namePrefix)
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.stream.typed
|
||||
|
||||
package object scaladsl {
|
||||
type ActorMaterializer = akka.stream.ActorMaterializer
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.stream.typed.scaladsl
|
||||
|
||||
import akka.actor.typed.ActorSystem
|
||||
import akka.stream.ActorMaterializerSettings
|
||||
|
||||
object ActorMaterializer {
|
||||
import akka.actor.typed.scaladsl.adapter._
|
||||
|
||||
/**
|
||||
* Creates an `ActorMaterializer` which will execute every step of a transformation
|
||||
* pipeline within its own [[akka.actor.Actor]]. The required [[akka.actor.typed.ActorSystem]]
|
||||
* will be used to create one actor that in turn creates actors for the transformation steps.
|
||||
*
|
||||
* The materializer's [[akka.stream.ActorMaterializerSettings]] will be obtained from the
|
||||
* configuration of the `context`'s underlying [[akka.actor.typed.ActorSystem]].
|
||||
*
|
||||
* The `namePrefix` is used as the first part of the names of the actors running
|
||||
* the processing steps. The default `namePrefix` is `"flow"`. The actor names are built up of
|
||||
* `namePrefix-flowNumber-flowStepNumber-stepName`.
|
||||
*/
|
||||
def apply[T](materializerSettings: Option[ActorMaterializerSettings] = None, namePrefix: Option[String] = None)(implicit actorSystem: ActorSystem[T]): ActorMaterializer =
|
||||
akka.stream.ActorMaterializer(materializerSettings, namePrefix)(actorSystem.toUntyped)
|
||||
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class ActorFlowCompileTest {
|
|||
|
||||
{
|
||||
final ActorSystem<String> system = null;
|
||||
final ActorMaterializer mat = akka.stream.typed.ActorMaterializer.create(system);
|
||||
final ActorMaterializer mat = ActorMaterializerFactory.create(system);
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class ActorSourceSinkCompileTest {
|
|||
|
||||
{
|
||||
final ActorSystem<String> system = null;
|
||||
final ActorMaterializer mat = akka.stream.typed.ActorMaterializer.create(system);
|
||||
final ActorMaterializer mat = ActorMaterializerFactory.create(system);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package akka.stream.typed.scaladsl
|
||||
|
||||
//#imports
|
||||
import akka.stream.typed.ActorMaterializer
|
||||
import akka.stream.typed.scaladsl.ActorMaterializer
|
||||
import akka.stream.scaladsl._
|
||||
|
||||
import akka.actor.typed.ActorRef
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import akka.stream.OverflowStrategy
|
|||
import akka.stream.scaladsl.Keep
|
||||
import akka.stream.scaladsl.Sink
|
||||
import akka.stream.scaladsl.Source
|
||||
import akka.stream.typed.ActorMaterializer
|
||||
import akka.actor.testkit.typed.scaladsl.{ ActorTestKit, _ }
|
||||
|
||||
object ActorSourceSinkSpec {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import akka.actor.typed.TypedAkkaSpecWithShutdown
|
|||
import akka.actor.typed.scaladsl.Behaviors
|
||||
import akka.stream.scaladsl.Sink
|
||||
import akka.stream.scaladsl.Source
|
||||
import akka.stream.typed.ActorMaterializer
|
||||
import akka.actor.testkit.typed.scaladsl.ActorTestKit
|
||||
|
||||
object CustomGuardianAndMaterializerSpec {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@
|
|||
package docs.akka.stream.typed
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.actor.typed.ActorSystem
|
||||
import akka.stream.typed.scaladsl.ActorMaterializer
|
||||
|
||||
object ActorSourceSinkExample {
|
||||
|
||||
implicit val mat: ActorMaterializer = ???
|
||||
val system: ActorSystem[_] = ???
|
||||
|
||||
implicit val mat: ActorMaterializer = ActorMaterializer()(system)
|
||||
|
||||
{
|
||||
// #actor-source-ref
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue