SuperCache.Cluster.Raft.Leadership (SuperCache v1.9.0)

Copy Markdown View Source

Graceful leadership handoff for a planned partition primary move.

The helper only acts on an explicit, planned change: it resolves the group's current leader, verifies that the incoming node is a caught-up voter, and asks the leader to hand over. Any failure is returned to the caller so the ownership path can fall back to the normal form/reconcile + election flow.

Summary

Functions

Transfer leadership of partition_idx to target_node, the new primary.

Functions

transfer(partition_idx, target_node)

@spec transfer(non_neg_integer(), node()) :: :ok | :not_needed | {:error, term()}

Transfer leadership of partition_idx to target_node, the new primary.

Returns :ok when the target already leads or the handover succeeded, :not_needed when no local Raft system is running, or {:error, reason} when the target is ineligible or the request fails.