From 11a658deb19a61ef7da69305997aeee42d317e1b Mon Sep 17 00:00:00 2001 From: Helena Edelson Date: Fri, 4 Oct 2019 02:08:34 -0700 Subject: [PATCH] =?UTF-8?q?Actor=20discovery:=20Don't=20start=20a=20page?= =?UTF-8?q?=20with=20referencing=20and=20describing=20h=E2=80=A6=20(#27880?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- akka-docs/src/main/paradox/general/addressing.md | 14 ++------------ .../src/main/paradox/typed/actor-discovery.md | 13 +++++++------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/akka-docs/src/main/paradox/general/addressing.md b/akka-docs/src/main/paradox/general/addressing.md index a5091f4809..f6091ed30a 100644 --- a/akka-docs/src/main/paradox/general/addressing.md +++ b/akka-docs/src/main/paradox/general/addressing.md @@ -11,7 +11,7 @@ distributed Akka application. The above image displays the relationship between the most important entities within an actor system, please read on for the details. -## What is an Actor Reference? +## What is an Actor Reference An actor reference is a subtype of `ActorRef`, whose foremost purpose is to support sending messages to the actor it represents. Each actor has access @@ -113,17 +113,7 @@ You cannot freely create actor paths like symbolic links to refer to arbitrary a ## How are Actor References obtained? There are two general categories to how actor references may be obtained: by -creating actors or by looking them up through the @ref:[Receptionist](../typed/actor-discovery.md#receptionist). - -### Creating Actors - -An actor system is started by creating actors beneath the user guardian -actor using the `ActorContext.spawn` method and then using -`ActorContext.spawn` from within the created actors to spawn the actor -tree. These methods return a reference to the newly created actor. Each actor -has direct access (through its `ActorContext`) to references for its parent, -itself and its children. These references may be sent within messages to other actors, -enabling those to reply directly. +@ref:[creating actors](../typed/actor-lifecycle.md#creating-actors) or by looking them up through the @ref:[Receptionist](../typed/actor-discovery.md#receptionist). ## Actor Reference and Path Equality diff --git a/akka-docs/src/main/paradox/typed/actor-discovery.md b/akka-docs/src/main/paradox/typed/actor-discovery.md index e31396535f..bfe8555afa 100644 --- a/akka-docs/src/main/paradox/typed/actor-discovery.md +++ b/akka-docs/src/main/paradox/typed/actor-discovery.md @@ -14,7 +14,10 @@ To use Akka Actor Typed, you must add the following dependency in your project: version=$akka.version$ } -## Introduction +## Obtaining Actor references + +There are two general ways to obtain @ref:[Actor references](../general/addressing.md#what-is-an-actor-reference): by +@ref:[creating actors](actor-lifecycle.md#creating-actors) and by discovery using the @ref:[Receptionist](#receptionist). You can pass actor references between actors as constructor parameters or part of messages. @@ -24,7 +27,8 @@ applicable. ## Receptionist -For this purpose there is an actor called the `Receptionist`. You register the specific actors that should be discoverable +When an actor needs to be discovered by another actor but you are unable to put a reference to it in an incoming message, +you can use the `Receptionist`. You register the specific actors that should be discoverable from other nodes in the local `Receptionist` instance. The API of the receptionist is also based on actor messages. This registry of actor references is then automatically distributed to all other nodes in the cluster. You can lookup such actors with the key that was used when they were registered. The reply to such a `Find` request is @@ -32,12 +36,9 @@ a `Listing`, which contains a `Set` of actor references that are registered for registered to the same key. The registry is dynamic. New actors can be registered during the lifecycle of the system. Entries are removed when -registered actors are stopped or a node is removed from the cluster. To facilitate this dynamic aspect you can also subscribe +registered actors are stopped or a node is removed from the @ref:[Cluster](cluster.md). To facilitate this dynamic aspect you can also subscribe to changes with the `Receptionist.Subscribe` message. It will send `Listing` messages to the subscriber when entries for a key are changed. -The primary scenario for using the receptionist is when an actor needs to be discovered by another actor but you are unable -to put a reference to it in an incoming message. - These imports are used in the following example: Scala