feat: support the flattening syntax for supervising#32465
feat: support the flattening syntax for supervising#32465
Conversation
7654d09 to
dfaccbc
Compare
patriknw
left a comment
There was a problem hiding this comment.
great that you picked up this
akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/Behaviors.scala
Outdated
Show resolved
Hide resolved
|
Retriggering CI after #32489 |
1597d12 to
92021e9
Compare
| Behaviors | ||
| .supervise(behavior) | ||
| .whenFailure[IllegalStateException](SupervisorStrategy.restart) | ||
| .whenFailure[IllegalArgumentException](SupervisorStrategy.stop) |
There was a problem hiding this comment.
We should show this as the main way now that we have it, not sure we need to show the other one at all
| whenFailure(strategy)(ClassTag(clazz)) | ||
|
|
||
| private[akka] def unwrap: Behavior[T] = wrapped | ||
| } |
There was a problem hiding this comment.
Unfortunate that the entire class needs to be public, but maybe separating in public trait and impl would be tricky. Make it final and replace "not for user extension" with "Not for user instantiation.
@InternalApi would mean the entire type is internal but we return it so drop that but put it on the unwrap method which becomes public from Java.
| */ | ||
| def onFailure[Thr <: Throwable](clazz: Class[Thr], strategy: SupervisorStrategy): Behavior[T] = | ||
| Supervisor(Behavior.validateAsInitial(wrapped), strategy)(ClassTag(clazz)) | ||
| new SuperviseBehavior[T](wrapped).whenFailure(clazz, strategy).unwrap |
There was a problem hiding this comment.
Would it not be safe to change the return type here to a subtype of Behavior and not need the separate whenFailure name?
References #31350