Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved complex typed supervision definitions #31350

Open
johanandren opened this issue Apr 19, 2022 · 1 comment
Open

Improved complex typed supervision definitions #31350

johanandren opened this issue Apr 19, 2022 · 1 comment
Labels
discuss-design Design discussion would be good t:typed

Comments

@johanandren
Copy link
Member

Supervising a typed actor with many different strategies for different exceptions currently creates a "pyramid of doom":

val myActor = system.spawn(
      Behaviors
        .supervise(
          Behaviors
            .supervise(
              Behaviors
                .supervise(Behaviors
                  .supervise(MyActor())
                  .onFailure[ExceptionA](SupervisorStrategy.stop.withLogLevel(Level.ERROR)))
                .onFailure[ExceptionB](SupervisorStrategy.stop.withLogLevel(Level.WARN)))
            .onFailure[ExceptionC](myRestartStrategy.withLogLevel(Level.WARN)))
        .onFailure[ExceptionD](myRestartStrategy.withLogLevel(Level.ERROR)),
      "my-actor")

It would be nice with an API that flattens such a set of supervisions to a shorter one that is easier to parse, perhaps something like:

val myActor = system.spawn(
      Behaviors
        .supervise(MyActor())
          .onFailure[ExceptionA](SupervisorStrategy.stop.withLogLevel(Level.ERROR))
          .onFailure[ExceptionB](SupervisorStrategy.stop.withLogLevel(Level.WARN))
          .onFailure[ExceptionC](myRestartStrategy.withLogLevel(Level.WARN))
          .onFailure[ExceptionD](myRestartStrategy.withLogLevel(Level.ERROR))),
      "my-actor")
@johanandren johanandren added t:typed discuss-design Design discussion would be good labels Apr 19, 2022
@patriknw
Copy link
Member

I agree. This came up previously in a discussion with @manuelbernhardt and then the suggestion was also the flat syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss-design Design discussion would be good t:typed
Projects
None yet
Development

No branches or pull requests

2 participants