Skip to content

feat: Immutable builder for interceptor and supervisor#680

Closed
Roiocam wants to merge 2 commits intoapache:mainfrom
Roiocam:flat-supervisor
Closed

feat: Immutable builder for interceptor and supervisor#680
Roiocam wants to merge 2 commits intoapache:mainfrom
Roiocam:flat-supervisor

Conversation

@Roiocam
Copy link
Member

@Roiocam Roiocam commented Sep 24, 2023

Draft because I haven't verified everything and I am not sure if this is the optimal approach.

Example usage could be like this:

val rawBehavior: Behavior[Command] = Behaviors.empty
val interceptor : BehaviorInterceptor[Command,Command] = ???
val monitorProbe = TestProbe[Command]("probe")

val behavior: Behavior[Command] = Behaviors.interceptorBuilder(rawBehavior)
  .onFailure[Exc1](SupervisorStrategy.restart.withStashCapacity(100))
  .onFailure[Exc2](SupervisorStrategy.restart.withStashCapacity(100))
  .intercept[Command](() => interceptor)
  .onFailure[Exc3](SupervisorStrategy.restart.withStashCapacity(100))
  .monitor(monitorProbe.ref)
  .build()

@Roiocam Roiocam marked this pull request as draft September 24, 2023 16:33
* wrapped in a `monitor` call again.
* The simple way of as [[Behaviors.monitor]]
*/
def monitor(monitor: ActorRef[T]): InterceptorBuilder[T] = {
Copy link
Member Author

Choose a reason for hiding this comment

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

After incrementing some additional methods, I have discovered that most of the methods can be flattened using this builder. It seems to be more like a BehaviorBuilder rather than an InterceptorBuilder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant