replication

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package replication implements the Replica-side Follow stream client. A Replica connects to the Primary, receives PrimaryMessages (records, commits, and compaction updates), persists records locally, and sends Receipts with embedded Heartbeats back to the Primary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Follower

type Follower struct {
	// contains filtered or unexported fields
}

Follower connects to the Primary's Follow RPC as a Replica, receives PrimaryMessages, persists records locally, and sends Receipts.

func NewFollower

func NewFollower(
	logger *slog.Logger,
	nodeID string,
	state *nodestate.State,
	peers *peerclient.Manager,
	db localdb.Database,
	heartbeatSender *heartbeat.Sender,
	watchManager *watch.Manager,
	replicaMetrics *Metrics,
	compactionMetrics *metrics.CompactionMetrics,
	retryMetrics *metrics.RetryMetrics,
) *Follower

NewFollower creates a new replication Follower.

func (*Follower) RequireInitialSync

func (f *Follower) RequireInitialSync()

RequireInitialSync marks the next Start call as a bootstrap start that must not return until the follower has either received the Primary's Initial message or determined that no remote Primary follow stream is needed.

func (*Follower) SetMetrics

func (f *Follower) SetMetrics(m *Metrics)

SetMetrics sets the Replica-scoped metrics reference.

func (*Follower) Start

func (f *Follower) Start(parent context.Context) error

Start begins the Follow stream loop in a background goroutine. It is a no-op if the follower is already running. When RequireInitialSync was called beforehand, Start blocks until that initial synchronization requirement has been satisfied.

func (*Follower) Stop

func (f *Follower) Stop()

Stop cancels the Follow stream loop. It is a no-op if the follower is not running.

type Metrics

type Metrics struct {
	ReceiptAge *receiptAgeGauge
}

Metrics holds Replica-scoped replication Prometheus metrics.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates Replica-scoped replication metrics.

func (*Metrics) Collectors

func (m *Metrics) Collectors() []prometheus.Collector

Collectors returns all Replica-scoped collectors for registration with a RoleGroup.

Jump to

Keyboard shortcuts

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