Documentation
¶
Overview ¶
Package cluster provides cluster-level coordination including leader election. This is distinct from shard-level coordination which is handled by the shard package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCAGenerationRequiresLeadership = errors.New("CA certificate needs generating, but this instance is not cluster leader")
ErrCAGenerationRequiresLeadership is returned when CA needs generation but this server is not leader.
Functions ¶
This section is empty.
Types ¶
type BootstrapConfig ¶
type BootstrapConfig struct {
// ElectionManager manages leader elections
ElectionManager *election.Manager
// ElectionConfig is the configuration for starting the cluster election
ElectionConfig election.ElectionConfig
// Storage is the cluster-scoped storage
Storage storage.Storage
// SecretsStore for encrypted secrets
SecretsStore secrets.Store
// CAConfig is the optional CA certificate configuration
CAConfig *config.CertConfig
// TemplateVars for CA generation
TemplateVars map[string]string
// Logger for bootstrap events
Logger *slog.Logger
}
BootstrapConfig contains configuration for cluster bootstrap.
type BootstrapResult ¶
BootstrapResult contains the results of cluster bootstrap.
func Bootstrap ¶
func Bootstrap(ctx context.Context, cfg BootstrapConfig, leaderElectionEnabled bool) (*BootstrapResult, error)
Bootstrap initializes cluster-level resources including CA and leader election. It handles: 1. Loading existing CA or determining if generation is needed 2. Starting leader election (if enabled) 3. Generating CA if this server becomes leader and CA is needed 4. Enabling peer mode once CA is available 5. Ensuring registration nonce key exists
Returns a BootstrapResult with CA cert and key, or an error. The caller is responsible for stopping the election manager.