feat: add timeout duration to ReceiveTimeout message - #3399
Open
He-Pin wants to merge 4 commits into
Open
Conversation
He-Pin
marked this pull request as draft
July 29, 2026 18:28
Motivation: ReceiveTimeout was a case object singleton carrying no information about the configured timeout duration, making it impossible to log or inspect the timeout value from the message handler without accessing context.receiveTimeout separately (#2569). Modification: Convert ReceiveTimeout from a case object to a final case class with a `timeout: FiniteDuration` field. The scheduler now sends ReceiveTimeout(duration) instead of the singleton. All pattern matches updated from stable identifier patterns to type patterns. Java API updated from matchEquals(getInstance()) to match(ReceiveTimeout.class). Result: Users can now access the timeout duration directly from the message: case timeout: ReceiveTimeout => log.info("timeout: {}", timeout.timeout)
Apply code formatting and update MiMa exclusion filters to match the exact binary compatibility problems reported by CI.
Motivation: The Binary Compatibility CI job failed on the Scala 3 lane: converting ReceiveTimeout from case object to case class produced three unfiltered problems for pekko-actor_3 (fromProduct result type, productElementNames and productIterator generic signatures). The new Java API getTimeout also lacked test coverage. Modification: Add the three Scala 3 MiMa exclusion filters reported by CI and assert getTimeout in the ReceiveTimeoutSpec timeout-duration test. Result: MiMa passes on both Scala 2.13 and Scala 3 and the Java API is covered. Tests: - sbt "actor-tests / Test / testOnly org.apache.pekko.actor.ReceiveTimeoutSpec" - 15 tests pass - sbt "++2.13.18!" "actor/mimaReportBinaryIssues" "++3.3.8!" "actor/mimaReportBinaryIssues" - pass - sbt checkMimaFilterDirectories - pass References: Refs #2569
He-Pin
force-pushed
the
feat/receive-timeout-with-duration
branch
from
August 4, 2026 05:29
e360324 to
1ca0652
Compare
He-Pin
marked this pull request as ready for review
August 4, 2026 06:18
pjfanning
reviewed
Aug 4, 2026
Motivation: Address review feedback on #3399 to use the standard Scala/Java duration conversion, and document the ReceiveTimeout breaking change for 2.x users. Modification: - Replace java.time.Duration.ofNanos(timeout.toNanos) with timeout.toJava via scala.jdk.DurationConverters in Actor.scala - Add a ReceiveTimeout entry to migration-guide-1.x-2.x.md Result: The Java API conversion follows the established codebase convention and the 2.x migration guide documents the pattern matching and getInstance breaking changes. Tests: - sbt "actor-tests / Test / testOnly org.apache.pekko.actor.ReceiveTimeoutSpec" - 15 tests passed - sbt "actor-typed-tests / Test / testOnly org.apache.pekko.actor.typed.CancelReceiveTimeoutSpec" - passed - sbt actor/mimaReportBinaryIssues - no issues - scalafmt --mode diff-ref=origin/main - no extra changes - git diff --check - clean References: Refs #3399
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReceiveTimeoutfrom acase objectsingleton to afinal case class ReceiveTimeout(timeout: FiniteDuration)so the message carries the configured timeout durationcase timeout: ReceiveTimeout => log.info("timeout: {}", timeout.timeout)Motivation
Previously
ReceiveTimeoutwas a case object with no information, making it impossible to log or inspect the timeout value without separately accessingcontext.receiveTimeout. As noted in the issue, this made logging awkward:Changes
actor/src/main/scala/.../Actor.scala: ConvertReceiveTimeoutfromcase objecttofinal case classwithtimeout: FiniteDurationfield and Java APIgetTimeoutmethodactor/src/main/scala/.../dungeon/ReceiveTimeout.scala: Scheduler now sendsReceiveTimeout(timeout)instead of the singletoncase ReceiveTimeout =>) to type patterns (case _: ReceiveTimeout =>)matchEquals(ReceiveTimeout.getInstance(), ...)tomatch(ReceiveTimeout.class, ...)Breaking changes (2.0)
ReceiveTimeoutis no longer a singleton; pattern matches must use type patternsReceiveTimeout.getInstance()removed; Java users should use.match(ReceiveTimeout.class, ...)Test plan
actor-tests/testOnly *.ReceiveTimeoutSpec— 15 tests pass (including new "carry the configured timeout duration" test)actor-typed-tests/testOnly *.CancelReceiveTimeoutSpec— passes