github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/actor/supervision_event.go (about)

     1  package actor
     2  
     3  import (
     4  	"log/slog"
     5  )
     6  
     7  // SupervisorEvent is sent on the EventStream when a supervisor have applied a directive to a failing child actor
     8  type SupervisorEvent struct {
     9  	Child     *PID
    10  	Reason    interface{}
    11  	Directive Directive
    12  }
    13  
    14  func SubscribeSupervision(actorSystem *ActorSystem) {
    15  	_ = actorSystem.EventStream.Subscribe(func(evt interface{}) {
    16  		if supervisorEvent, ok := evt.(*SupervisorEvent); ok {
    17  			actorSystem.Logger().Debug("[SUPERVISION]", slog.Any("actor", supervisorEvent.Child), slog.Any("directive", supervisorEvent.Directive), slog.Any("reason", supervisorEvent.Reason))
    18  		}
    19  	})
    20  }