Skip to content
Leader docs0.4

Execution APIs

Latest stable Based on Leader release 0.4.0

Map each interface to its lambda, return type, scheduler, and cancellation surface.

LeaderElector accepts () -> T and returns T?. AsyncLeaderElector accepts () -> CompletableFuture<T> and returns CompletableFuture<T?>. VirtualThreadLeaderElector accepts () -> T and returns VirtualFuture<T?>. SuspendLeaderElector accepts a suspend lambda and returns T?. Group interfaces mirror the blocking and suspend shapes.

Choose the interface at the application boundary. Wrapping a blocking backend in a coroutine does not make its I/O non-blocking, and nesting arbitrary thread hops can break thread-bound ownership such as Redisson extension. Prefer the backend’s native interface.

LeaderSlot carries a lock name and audit leader id. Default bridge overloads warn and cannot prove that a backend stamped the supplied identity; backend implementations should override slot and result variants. Do not assume Elected.leaderId is populated when a bridge path returns null.