Skip to content

Mailbox selection for Akka Typed actors - #27183

Merged
johanandren merged 8 commits into
akka:masterfrom
johanandren:wip-27124-mailbox-selector-props-typed-johanandren
Jul 16, 2019
Merged

johanandren merged 8 commits into
akka:masterfrom
johanandren:wip-27124-mailbox-selector-props-typed-johanandren

Conversation

@johanandren

Copy link
Copy Markdown
Contributor

Purpose

Allow for selection of mailbox type in Akka Typed through Props

References

Fixes #27124

Changes

New API MailboxSelector, support in PropsAdapter, hack in akka-actor to allow for programmatic passing of bounded mailbox capacity from typed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels Jun 19, 2019
@akka-ci

akka-ci commented Jun 19, 2019

Copy link
Copy Markdown

Test FAILed.

// mailbox configurators for the same size
val capacity = id.split(':')(1).toInt
new BoundedMailbox(capacity, Duration.Zero)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly my proudest moment encoding this in strings but allowed for minimal changes in untyped + caching of the configurator.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caching argument is good. I think it's ok.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jun 19, 2019
@akka-ci

akka-ci commented Jun 19, 2019

Copy link
Copy Markdown

Test FAILed.

Comment thread akka-actor-typed/src/main/scala/akka/actor/typed/Props.scala Outdated
Comment thread akka-actor-typed/src/main/scala/akka/actor/typed/Props.scala Outdated
Comment thread akka-actor/src/main/scala/akka/dispatch/Mailboxes.scala

@patriknw patriknw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

Comment thread akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala Outdated
Comment thread akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala Outdated
Comment thread akka-actor-typed-tests/src/test/scala/docs/akka/typed/MailboxDocSpec.scala Outdated
Comment thread akka-actor-typed/src/main/scala/akka/actor/typed/Props.scala Outdated
Comment thread akka-actor/src/main/scala/akka/dispatch/Mailboxes.scala Outdated
// mailbox configurators for the same size
val capacity = id.split(':')(1).toInt
new BoundedMailbox(capacity, Duration.Zero)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caching argument is good. I think it's ok.

Comment thread akka-docs/src/main/paradox/typed/mailboxes.md Outdated
@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jun 28, 2019
@akka-ci

akka-ci commented Jun 28, 2019

Copy link
Copy Markdown

Test FAILed.

@johanandren
johanandren force-pushed the wip-27124-mailbox-selector-props-typed-johanandren branch from ea46524 to f6d24db Compare July 10, 2019 13:50
@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jul 10, 2019
@akka-ci

akka-ci commented Jul 10, 2019

Copy link
Copy Markdown

Test PASSed.

@patriknw patriknw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with some minor nits

Comment thread akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala Outdated
Comment thread akka-actor-typed/src/main/scala/akka/actor/typed/Props.scala Outdated
Comment thread akka-actor-typed/src/main/scala/akka/actor/typed/Props.scala Outdated
Comment thread akka-docs/src/main/paradox/typed/mailboxes.md Outdated
@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jul 11, 2019
@akka-ci

akka-ci commented Jul 11, 2019

Copy link
Copy Markdown

Test PASSed.

@jrudolph jrudolph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

/**
* Scala API: The default mailbox is unbounded and backed by a [[java.util.concurrent.ConcurrentLinkedQueue]]
*/
def default(): MailboxSelector = DefaultMailboxSelector.empty

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need parentheses for the Scala version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe not, on the fence, on one hand it is a constant/no side effect on the other hand maybe that fact is an implementation detail. This is aligned with the dispatcher selector though.

@@ -202,8 +206,14 @@ private[akka] class Mailboxes(
// It doesn't matter if we create a mailbox type configurator that isn't used due to concurrent lookup.
val newConfigurator = id match {
// TODO RK remove these two for Akka 2.3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, that TODO slipped it seems...

case _ if id.startsWith(BoundedCapacityPrefix) =>
// hack to allow programmatic set of capacity through props in akka-typed but still share
// mailbox configurators for the same size
val capacity = id.split(':')(1).toInt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's ok for us if that fails with a cryptic exception in case we or someone else doesn't follow the format.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not public API in any way

…ter/PropsAdapter.scala

Co-Authored-By: Johannes Rudolph <johannes.rudolph@gmail.com>
@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jul 16, 2019
@akka-ci

akka-ci commented Jul 16, 2019

Copy link
Copy Markdown

Test PASSed.

@johanandren
johanandren merged commit 2626f17 into akka:master Jul 16, 2019
@johanandren
johanandren deleted the wip-27124-mailbox-selector-props-typed-johanandren branch July 16, 2019 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tested PR that was successfully built and tested by Jenkins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mailbox selector props in Typed

5 participants