effectKey

infix fun <C, R> SagaStep<C, R>.effectKey(block: suspend (C) -> String): SagaStep<C, R>

Attaches an effect-key lambda to this SagaStep, returning a new copy.

The lambda receives the current context C (no state, for stateless sagas) and must return a non-blank string that uniquely identifies the step's side effect within a run.

Example

step(OrderStep.CHARGE) { ctx ->
chargeService.charge(ctx.orderId, ctx.amount)
} effectKey { ctx ->
"charge:${ctx.orderId}:${ctx.amount}"
}

Blank-string validation happens at Intent-append time (T010), not here.


infix fun <C, R, S : Any> StatefulSagaStep<C, R, S>.effectKey(block: suspend (C, S) -> String): StatefulSagaStep<C, R, S>

Attaches an effect-key lambda to this StatefulSagaStep, returning a new copy.

The lambda receives the current context C and the pre-step saga state S and must return a non-blank string that uniquely identifies the step's side effect within a run.

Example

step(OrderStep.CHARGE) { ctx ->
chargeService.charge(ctx.orderId, state.pendingAmount)
} effectKey { ctx, state ->
"charge:${ctx.orderId}:${state.pendingAmount}"
}

Blank-string validation happens at Intent-append time (T010), not here.