addInterceptor

open fun addInterceptor(interceptor: SagaInterceptor<C, R, S>)

Add an interceptor to observe and potentially veto saga step execution.

Interceptors are invoked before and after each step (Before → After, LIFO for After), and after each compensation action. An interceptor returning InterceptorOutcome.Veto from a StepPhase.Before phase prevents the step from executing.

The interceptor receives the current saga state S as a read-only snapshot (stateHolder.get()). Interceptors cannot mutate the saga state — state changes remain the responsibility of step bodies via updateState { }.

Default implementation throws UnsupportedOperationException — only overridden in StatefulSagaExecutorImpl.

Parameters

interceptor

The interceptor to add