small Typed doc improvements

This commit is contained in:
Patrik Nordwall 2018-02-02 17:18:31 +01:00
parent 570060815b
commit d8c9a9ca8c
12 changed files with 37 additions and 50 deletions

View file

@ -41,8 +41,8 @@ object BasicSyncTestingSpec {
case (_, SayHello(who))
who ! "hello"
Behaviors.same
//#under-test
}
//#under-test
}

View file

@ -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

View file

@ -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<Greeted>`], 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` Actors
`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

View file

@ -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.

View file

@ -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

View file

@ -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 }

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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.

View file

@ -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

View file

@ -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)