diff --git a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/testing/sync/BasicSyncTestingSpec.scala b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/testing/sync/BasicSyncTestingSpec.scala index fb91db1492..54ce1db696 100644 --- a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/testing/sync/BasicSyncTestingSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/testing/sync/BasicSyncTestingSpec.scala @@ -41,8 +41,8 @@ object BasicSyncTestingSpec { case (_, SayHello(who)) ⇒ who ! "hello" Behaviors.same - //#under-test } + //#under-test } diff --git a/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala b/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala index 176c0083b4..8d6179a5f7 100644 --- a/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala +++ b/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala @@ -62,11 +62,11 @@ object ShardingCompileOnlySpec { //#persistence val ShardingTypeName = EntityTypeKey[BlogCommand]("BlogPost") ClusterSharding(system).spawn[BlogCommand]( - behavior = _ ⇒ InDepthPersistentBehaviorSpec.behavior, + behavior = entityId ⇒ InDepthPersistentBehaviorSpec.behavior(entityId), props = Props.empty, typeKey = ShardingTypeName, settings = ClusterShardingSettings(system), - maxNumberOfShards = 10, + maxNumberOfShards = 100, handOffStopMessage = PassivatePost) //#persistence diff --git a/akka-docs/src/main/paradox/typed/actors.md b/akka-docs/src/main/paradox/typed/actors.md index 1f1e5f938b..3f390862bd 100644 --- a/akka-docs/src/main/paradox/typed/actors.md +++ b/akka-docs/src/main/paradox/typed/actors.md @@ -11,7 +11,7 @@ This module is currently marked as @ref:[may change](../common/may-change.md) in ## Dependency -To use Akka Typed add the following dependency: +To use Akka Actor Typed add the following dependency: @@dependency[sbt,Maven,Gradle] { group=com.typesafe.akka @@ -63,7 +63,7 @@ also typed as such. This is why we can access the `whom` and `replyTo` members without needing to use a pattern match. On the last line we see the `HelloWorld` Actor send a message to another -Actor, which is done using the @scala[`!` operator (pronounced “tell”).]@java[`tell` method.] +Actor, which is done using the @scala[`!` operator (pronounced “bang” or “tell”).]@java[`tell` method.] Since the `replyTo` address is declared to be of type @scala[`ActorRef[Greeted]`]@java[`ActorRef`], the compiler will only permit us to send messages of this type, other usage will not be accepted. @@ -265,24 +265,9 @@ Therefore after creating the Actor system with the `main` Actor’s `Behavior` we just await its termination. -## Status of this Project and Relation to Akka Actors - -Akka Typed is the result of many years of research and previous attempts -(including Typed Channels in the 2.2.x series) and it is on its way to -stabilization, but maturing such a profound change to the core concept of Akka -will take a long time. We expect that this module will stay marked -@ref:[may change](../common/may-change.md) for multiple major releases of Akka and the -plain `akka.actor.Actor` will not be deprecated or go away anytime soon. - -Being a research project also entails that the reference documentation is not -as detailed as it will be for a final version, please refer to the API -documentation for greater depth and finer detail. - -### Main Differences +## Relation to Akka (untyped) Actors The most prominent difference is the removal of the `sender()` functionality. -This turned out to be the Achilles heel of the Typed Channels project, it is -the feature that makes its type signatures and macros too complex to be viable. The solution chosen in Akka Typed is to explicitly include the properly typed reply-to address in the message, which both burdens the user with this task but also places this aspect of protocol design where it belongs. @@ -297,9 +282,9 @@ have been converted into Signals. A side-effect of this is that behaviors can now be tested in isolation without having to be packaged into an Actor, tests can run fully synchronously without having to worry about timeouts and spurious failures. Another side-effect is -that behaviors can nicely be composed and decorated, see `tap`, or -@scala[`widen`]@java[`widened`] combinators; nothing about these is special or internal, new -combinators can be written as external libraries or tailor-made for each project. +that behaviors can nicely be composed and decorated, for example `Behaviors.tap` +is not special or using something internal. New combinators can be written as +external libraries or tailor-made for each project. ## A Little Bit of Theory @@ -353,11 +338,3 @@ Actor to continue the conversation by sending a message of type B to this new address. While we cannot statically express the “current” state of an Actor, we can express the current state of a protocol between two Actors, since that is just given by the last message type that was received or sent. - -## Migrating - -### Migrating to 2.5.9 - -* `EffectfulActorContext` has been renamed to `BehaviourTestKit` -* `Inbox` has been renamed to `TestInbox` to allign with `TestProbe` -* Separated into modules e.g. `akka-actor-typed` `akka-persistence-typed` along with matching package names diff --git a/akka-docs/src/main/paradox/typed/cluster-sharding.md b/akka-docs/src/main/paradox/typed/cluster-sharding.md index 33166c647f..6106fde490 100644 --- a/akka-docs/src/main/paradox/typed/cluster-sharding.md +++ b/akka-docs/src/main/paradox/typed/cluster-sharding.md @@ -14,7 +14,7 @@ This module is currently marked as @ref:[may change](../common/may-change.md) in ## Dependency -To use Akka Cluster Sharding, add the module to your project: +To use Akka Cluster Sharding Typed, add the module to your project: @@dependency[sbt,Maven,Gradle] { group=com.typesafe.akka @@ -74,5 +74,5 @@ To create the entity: Scala : @@snip [ShardingCompileOnlySpec.scala]($akka$/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala) { #persistence } -Sending messages to entities is the same as the example above. The only difference is ow when an entity is moved the state will be restored. +Sending messages to entities is the same as the example above. The only difference is when an entity is moved the state will be restored. See @ref:[persistence](persistence.md) for more details. diff --git a/akka-docs/src/main/paradox/typed/cluster-singleton.md b/akka-docs/src/main/paradox/typed/cluster-singleton.md index 8d50685184..91eb711f60 100644 --- a/akka-docs/src/main/paradox/typed/cluster-singleton.md +++ b/akka-docs/src/main/paradox/typed/cluster-singleton.md @@ -27,7 +27,7 @@ This module is currently marked as @ref:[may change](../common/may-change.md) in ## Dependency -To use Akka Cluster Singleton, add the module to your project: +To use Akka Cluster Singleton Typed, add the module to your project: @@dependency[sbt,Maven,Gradle] { group=com.typesafe.akka diff --git a/akka-docs/src/main/paradox/typed/cluster.md b/akka-docs/src/main/paradox/typed/cluster.md index 9016cb40a6..637c01efc1 100644 --- a/akka-docs/src/main/paradox/typed/cluster.md +++ b/akka-docs/src/main/paradox/typed/cluster.md @@ -32,7 +32,7 @@ Scala Java : @@snip [BasicClusterExampleTest.java]($akka$/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java) { #cluster-imports } -And the minimum configuration required is to set a host/port for remoting and the `cluster` +And the minimum configuration required is to set a host/port for remoting and the `akka.actor.provider = "cluster"`. Scala : @@snip [BasicClusterExampleTest.java]($akka$/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java) { #cluster-imports } diff --git a/akka-docs/src/main/paradox/typed/coexisting.md b/akka-docs/src/main/paradox/typed/coexisting.md index 78d4149133..d7e0eadc97 100644 --- a/akka-docs/src/main/paradox/typed/coexisting.md +++ b/akka-docs/src/main/paradox/typed/coexisting.md @@ -4,8 +4,6 @@ We believe Akka Typed will be adopted in existing systems gradually and therefor and untyped actors together, within the same `ActorSystem`. Also, we will not be able to integrate with all existing modules in one big bang release and that is another reason for why these two ways of writing actors must be able to coexist. There are two different `ActorSystem`s: `akka.actor.ActorSystem` and `akka.actor.typed.ActorSystem`. -The latter should only be used for greenfield projects that are only using typed actors. The `akka.actor.ActorSystem` -can be adapted so that it can create typed actors. Currently the typed actor system is implemented using an untyped actor system under the hood. This may change in the future. @@ -17,12 +15,16 @@ Typed and untyped can interact the following ways: * watch typed from untyped, and opposite * untyped actor system can be converted to a typed actor system -@scala[In the examples the `akka.actor` package is aliased to `untyped`.] @java[The examples use fully qualified -class names for the untyped classes to distinguish between typed and untyped classes with the same name.] +@@@ div { .group-scala } +In the examples the `akka.actor` package is aliased to `untyped`. Scala : @@snip [UntypedWatchingTypedSpec.scala]($akka$/akka-actor-typed-tests/src/test/scala/docs/akka/typed/coexistence/UntypedWatchingTypedSpec.scala) { #import-alias } +@@@ + +@java[The examples use fully qualified class names for the untyped classes to distinguish between typed and untyped classes with the same name.] + ## Untyped to typed While coexisting your application will likely still have an untyped ActorSystem. This can be converted to a typed ActorSystem diff --git a/akka-docs/src/main/paradox/typed/distributed-data.md b/akka-docs/src/main/paradox/typed/distributed-data.md new file mode 100644 index 0000000000..14b2c9f5e6 --- /dev/null +++ b/akka-docs/src/main/paradox/typed/distributed-data.md @@ -0,0 +1,5 @@ +# Distributed Data + +TODO https://github.com/akka/akka/issues/24494 + +See [https://akka.io/blog/2017/10/04/typed-cluster-tools](https://akka.io/blog/2017/10/04/typed-cluster-tools) diff --git a/akka-docs/src/main/paradox/typed/index.md b/akka-docs/src/main/paradox/typed/index.md index 6ff1753eb7..a79bcb186b 100644 --- a/akka-docs/src/main/paradox/typed/index.md +++ b/akka-docs/src/main/paradox/typed/index.md @@ -13,6 +13,7 @@ * [stash](stash.md) * [stream](stream.md) * [cluster](cluster.md) +* [distributed-data](distributed-data.md) * [cluster-singleton](cluster-singleton.md) * [cluster-sharding](cluster-sharding.md) * [persistence](persistence.md) diff --git a/akka-docs/src/main/paradox/typed/stream.md b/akka-docs/src/main/paradox/typed/stream.md index 94eea947cc..ea17cfbc7e 100644 --- a/akka-docs/src/main/paradox/typed/stream.md +++ b/akka-docs/src/main/paradox/typed/stream.md @@ -1,17 +1,23 @@ # Streams +@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`. + +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. + @@@ warning This module is currently marked as @ref:[may change](../common/may-change.md) in the sense of being the subject of active research. This means that API or semantics can change without warning or deprecation period and it is not recommended to use this module in production just yet—you have been warned. - + @@@ -@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. +## Dependency -To use the typed stream source and sink factories add the following dependency: +To use Akka Streams Typed, add the module to your project: @@dependency [sbt,Maven,Gradle] { group=com.typesafe.akka @@ -19,10 +25,6 @@ To use the typed stream source and sink factories add the following dependency: version=$akka.version$ } -This dependency 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 take 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. - ## Actor Source A stream that is driven by messages sent to a particular actor can be started with @scala[@scaladoc[`ActorSource.actorRef`](akka.stream.typed.scaladsl.ActorSource#actorRef)]@java[@javadoc[`ActorSource.actorRef`](akka.stream.typed.javadsl.ActorSource#actorRef)]. This source materializes to a typed `ActorRef` which only accepts messages that are of the same type as the stream. diff --git a/akka-docs/src/main/paradox/typed/testing.md b/akka-docs/src/main/paradox/typed/testing.md index 04af55d358..0dc9cdcc6a 100644 --- a/akka-docs/src/main/paradox/typed/testing.md +++ b/akka-docs/src/main/paradox/typed/testing.md @@ -20,7 +20,7 @@ This module is currently marked as @ref:[may change](../common/may-change.md) in ## Dependency -To use Akka TestKit Type, add the module to your project: +To use Akka TestKit Typed, add the module to your project: @@dependency[sbt,Maven,Gradle] { group=com.typesafe.akka diff --git a/akka-persistence-typed/src/test/scala/docs/akka/persistence/typed/InDepthPersistentBehaviorSpec.scala b/akka-persistence-typed/src/test/scala/docs/akka/persistence/typed/InDepthPersistentBehaviorSpec.scala index 63efa5985c..604980a04f 100644 --- a/akka-persistence-typed/src/test/scala/docs/akka/persistence/typed/InDepthPersistentBehaviorSpec.scala +++ b/akka-persistence-typed/src/test/scala/docs/akka/persistence/typed/InDepthPersistentBehaviorSpec.scala @@ -116,9 +116,9 @@ object InDepthPersistentBehaviorSpec { //#event-handler //#behavior - def behavior: Behavior[BlogCommand] = + def behavior(entityId: String): Behavior[BlogCommand] = PersistentBehaviors.immutable[BlogCommand, BlogEvent, BlogState]( - persistenceId = "abc", + persistenceId = "Blog-" + entityId, initialState = BlogState.empty, commandHandler, eventHandler)