coordination

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package coordination defines the L2 cluster coordination abstraction. See docs/architecture.md.

Index

Constants

View Source
const (
	ProviderRaft       = "raft"
	ProviderEtcd       = "etcd"
	ProviderConsul     = "consul"
	ProviderKubernetes = "kubernetes"
	ProviderZooKeeper  = "zookeeper"
)

Variables

View Source
var (
	ErrProviderNotImplemented = errors.New("coordination provider not implemented")
	ErrNotSupported           = errors.New("operation not supported by this coordinator")
	ErrNotLeader              = errors.New("not coordination leader")
)

Functions

This section is empty.

Types

type ClusterView

type ClusterView struct {
	LeaderID       string
	LeaderDatabase DatabaseEndpoint
	Members        []Member
	Epoch          uint64
	ViewID         uint64
}

ClusterView is a snapshot of coordination state.

type Coordinator

type Coordinator interface {
	Start(ctx context.Context) error
	Stop() error

	LocalID() string
	IsLeader() bool
	ClusterView(ctx context.Context) (ClusterView, error)
	Watch(ctx context.Context) (<-chan ClusterView, error)

	AddMember(ctx context.Context, id string) error
	RemoveMember(ctx context.Context, id string) error

	// Dynamic cluster config blob — schema TBD (docs/architecture.md §4.1).
	GetClusterConfig(ctx context.Context) ([]byte, error)
	SetClusterConfig(ctx context.Context, cfg []byte) error
}

Coordinator abstracts cluster membership and leadership regardless of backend (embedded Raft, etcd, …).

type DatabaseEndpoint

type DatabaseEndpoint struct {
	Host string
	Port int
}

DatabaseEndpoint is the replication target for the current primary mysqld/postgres.

type Member

type Member struct {
	ID       string
	Name     string
	Database string // mysql | postgresql
	Tags     map[string]bool
	Meta     map[string]string
}

Member is a registered cluster member (NeoHA agent).

Directories

Path Synopsis
Package clusterconfig defines the JSON document stored in DCS for dynamic failover policy (shared across MySQL and PostgreSQL).
Package clusterconfig defines the JSON document stored in DCS for dynamic failover policy (shared across MySQL and PostgreSQL).
Package etcd provides an etcd-backed coordination.Coordinator (Patroni-style leader lease).
Package etcd provides an etcd-backed coordination.Coordinator (Patroni-style leader lease).
Package raftadapter wraps internal/election/raft as coordination.Coordinator.
Package raftadapter wraps internal/election/raft as coordination.Coordinator.
Package wire constructs coordination.Coordinator implementations from config.
Package wire constructs coordination.Coordinator implementations from config.

Jump to

Keyboard shortcuts

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