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.
Nullable API
Section titled “Nullable API”runIfLeader(): T? is concise: the action result means elected and null means skipped. If T itself is nullable, the two cases are intentionally ambiguous.
Explicit result
Section titled “Explicit result”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.
Control-flow exceptions
Section titled “Control-flow exceptions”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.
Release sources
Section titled “Release sources”leader-core/src/main/kotlin/io/bluetape4k/leader/LeaderRunResult.ktleader-core/src/main/kotlin/io/bluetape4k/leader/LeaderElector.ktleader-core/src/test/kotlin/io/bluetape4k/leader/LeaderRunResultTest.kt