additional mailbox selector for typed props (#1096)

* additional mailbox selector for typed props

* add unit test

* chore change of unit test

* Revert "configuration typo"

This reverts commit 7917feb32a4b042124513d98068db832cc59a541.

* fix pekko imports

* mention interoperability in doc

* share configuration in tests

* revert configuration change

* fix new typo

* fix jdocs tests

* optimized import

* mention api version in doc

* resolve import issue
This commit is contained in:
Andy(Jingzhang)Chen 2024-08-29 02:12:35 +08:00 committed by GitHub
parent db8d20ddea
commit d1ec224330
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 283 additions and 18 deletions

View file

@ -55,7 +55,7 @@ A default dispatcher is used for all actors that are spawned without specifying
This is suitable for all actors that don't block. Blocking in actors needs to be carefully managed, more
details @ref:[here](#blocking-needs-careful-management).
To select a dispatcher use `DispatcherSelector` to create a `Props` instance for spawning your actor:
To select a dispatcher use @apidoc[DispatcherSelector](DispatcherSelector$) to create a @apidoc[Props](typed.Props) instance for spawning your actor:
Scala
: @@snip [DispatcherDocSpec.scala](/actor-typed-tests/src/test/scala/docs/org/apache/pekko/typed/DispatchersDocSpec.scala) { #spawn-dispatcher }
@ -74,6 +74,17 @@ The final example shows how to load a custom dispatcher from configuration and r
<!-- Same between Java and Scala -->
@@snip [DispatcherDocSpec.scala](/actor-typed-tests/src/test/scala/docs/org/apache/pekko/typed/DispatchersDocSpec.scala) { #config }
### Interoperability with MailboxSelector
The @apidoc[DispatcherSelector](DispatcherSelector$) will create a @apidoc[Props](typed.Props) instance that can be both set up Dispatcher and Mailbox,
which means that you can continue to set up Mailbox through chain calls.
Scala
: @@snip [DispatcherDocSpec.scala](/actor-typed-tests/src/test/scala/docs/org/apache/pekko/typed/DispatchersDocSpec.scala) { #interoperability-with-mailbox }
Java
: @@snip [DispatcherDocTest.java](/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/DispatchersDocTest.java) { #interoperability-with-mailbox }
## Types of dispatchers
There are 2 different types of message dispatchers:

View file

@ -58,6 +58,17 @@ configuration section from the @apidoc[ActorSystem](typed.ActorSystem) configura
`id` key with the configuration path of the mailbox type and adding a
fall-back to the default mailbox configuration section.
### Interoperability with DispatcherSelector
The @apidoc[MailboxSelector](MailboxSelector$) will create a @apidoc[Props](typed.Props) instance that can be both set up Dispatcher and Mailbox,
which means that you can continue to set up Dispatcher through chain calls.
Scala
: @@snip [MailboxDocSpec.scala](/actor-typed-tests/src/test/scala/docs/org/apache/pekko/typed/MailboxDocSpec.scala) { #interoperability-with-dispatcher }
Java
: @@snip [MailboxDocTest.java](/actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/MailboxDocTest.java) { #interoperability-with-dispatcher }
## Mailbox Implementations
Pekko ships with a number of mailbox implementations: