He-Pin opened a new pull request, #3399:
URL: https://github.com/apache/pekko/pull/3399
## Summary
- Convert `ReceiveTimeout` from a `case object` singleton to a `final case
class ReceiveTimeout(timeout: FiniteDuration)` so the message carries the
configured timeout duration
- Users can now access the timeout directly from the message handler: `case
timeout: ReceiveTimeout => log.info("timeout: {}", timeout.timeout)`
- Closes #2569
## Motivation
Previously `ReceiveTimeout` was a case object with no information, making it
impossible to log or inspect the timeout value without separately accessing
`context.receiveTimeout`. As noted in the issue, this made logging awkward:
```java
case ReceiveTimeout timeout -> {
log.info("SessionEntity [{}] receive timeout :[{}], will stop itself",
timeout, getSelf().path());
getContext().stop(getSelf());
}
```
## Changes
- **`actor/src/main/scala/.../Actor.scala`**: Convert `ReceiveTimeout` from
`case object` to `final case class` with `timeout: FiniteDuration` field and
Java API `getTimeout` method
- **`actor/src/main/scala/.../dungeon/ReceiveTimeout.scala`**: Scheduler now
sends `ReceiveTimeout(timeout)` instead of the singleton
- **All pattern matches**: Updated from stable identifier patterns (`case
ReceiveTimeout =>`) to type patterns (`case _: ReceiveTimeout =>`)
- **Java API**: Updated from `matchEquals(ReceiveTimeout.getInstance(),
...)` to `match(ReceiveTimeout.class, ...)`
- **MiMa filters**: Added binary compatibility exclusion for 2.0.x
- **Tests**: Added new test verifying the timeout duration is carried
correctly
## Breaking changes (2.0)
- `ReceiveTimeout` is no longer a singleton; pattern matches must use type
patterns
- `ReceiveTimeout.getInstance()` removed; Java users should use
`.match(ReceiveTimeout.class, ...)`
## Test plan
- [x] `actor-tests/testOnly *.ReceiveTimeoutSpec` — 15 tests pass (including
new "carry the configured timeout duration" test)
- [x] `actor-typed-tests/testOnly *.CancelReceiveTimeoutSpec` — passes
- [x] All affected modules compile: actor, actor-typed, cluster,
cluster-tools, cluster-sharding, distributed-data, persistence, docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]