leaderrunner

package
v0.1.0-alpha.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package leaderrunner factors the "run this loop only while we hold raft leadership" boilerplate shared by every leader-gated control-plane loop (scheduler, orchestrator, dispatcher, janitors). Each such loop used to reimplement the same wait-for-leadership/re-check dance; Run centralizes it so leadership transitions are handled one way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, store Store, clk clock.Clock, leaderLoop func(context.Context))

Run invokes leaderLoop whenever this node holds leadership and blocks until ctx is canceled. leaderLoop is expected to return promptly once it observes leadership loss (via the store's LeaderCh or an ErrNotLeader apply); Run then waits for the next election and re-invokes it. leaderLoop receives ctx directly, so a daemon shutdown unwinds it too.

Types

type Store

type Store interface {
	IsLeader() bool
	LeaderCh() <-chan bool
}

Store is the slice of the raft store a leader-gated loop needs: whether this node currently leads, and a channel that fires on every leadership change.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL