[READ-ONLY] Mirror of https://github.com/andrioid/statesman. xstate inspired schema compatible statechart library for Go
fsm go statecharts
0

Configure Feed

Select the types of activity you want to include in your feed.

statesman / observer.go
1.2 kB 29 lines
1package statesman 2 3import "context" 4 5// TransitionObserver is notified synchronously at the observer point of each 6// committed-or-aborted microstep (before publish; docs/persistence-contract.md 7// §1). Returning an error aborts the transition with full rollback and takes the 8// actor terminal (decision 26). The durable layer registers as one of these. 9// 10// Observers run on the actor goroutine and MUST NOT call Send on the actor they 11// observe — a synchronous self-Send deadlocks the loop. Emit side effects via 12// ActionResult (the outbox) instead (decision 26; architecture §observer-induced 13// deadlock). 14type TransitionObserver[TCtx any, TEvt EventBase] interface { 15 OnTransition(ctx context.Context, before, after Snapshot[TCtx], evt TEvt) error 16} 17 18// ActorObserver is notified of actor lifecycle edges. Non-blocking; the runtime 19// calls these on the actor goroutine. 20type ActorObserver interface { 21 OnActorStart(addr ActorAddress) 22 OnActorStop(addr ActorAddress, reason error) 23} 24 25// TimerObserver is notified when `after` timers are scheduled and fire. 26type TimerObserver interface { 27 OnTimerScheduled(t ScheduledTimer) 28 OnTimerFired(t ScheduledTimer) 29}