Skip to content
Leader docs0.4

Result semantics

Latest stable Based on Leader release 0.4.0

Know whether an action ran, was skipped, or failed—even when the action can return null.

runIfLeader(): T? is concise: the action result means elected and null means skipped. If T itself is nullable, the two cases are intentionally ambiguous.

LeaderRunResult.Elected(value, leaderId?) proves the action ran, and value may still be null. Skipped means acquisition did not succeed. ActionFailed(cause) means ownership was acquired and the action started but failed. Election/backend errors before action start are thrown instead of being mislabeled as action failures.

CancellationException is propagated, not wrapped. Blocking paths restore the interrupt flag before rethrowing InterruptedException. Future and virtual-thread callers should expect exceptional completion and inspect the underlying cause at the consumption boundary.