replication

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package replication provides the push-based replication manager for the registry server and directory-sync support types. The Manager maintains a set of standby subscriber connections and broadcasts snapshots/deltas to all of them. Directory-sync types and helpers used by the server-side handler are also defined here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolField

func BoolField(m map[string]interface{}, key string) bool

func CloneSliceString

func CloneSliceString(s []string) []string

CloneSliceString returns a defensive copy. nil-in → nil-out.

func CloneSliceUint16

func CloneSliceUint16(s []uint16) []uint16

CloneSliceUint16 returns a defensive copy. nil-in → nil-out.

func CloneSliceUint32

func CloneSliceUint32(s []uint32) []uint32

CloneSliceUint32 returns a defensive copy. nil-in → nil-out.

func NormalizeExternalID

func NormalizeExternalID(id string) string

NormalizeExternalID normalizes to lowercase so lookups are case-insensitive.

func StrField

func StrField(m map[string]interface{}, key string) string

Types

type DirectoryEntry

type DirectoryEntry struct {
	ExternalID  string   `json:"external_id"` // unique ID from directory (OIDC sub, email, GUID)
	DisplayName string   `json:"display_name,omitempty"`
	Email       string   `json:"email,omitempty"`
	Groups      []string `json:"groups,omitempty"`   // directory groups
	Role        string   `json:"role,omitempty"`     // desired pilot role: "owner", "admin", "member"
	Disabled    bool     `json:"disabled,omitempty"` // deprovisioned users
}

DirectoryEntry represents a user from an enterprise directory (AD, Entra ID, LDAP).

func ParseDirectoryEntries

func ParseDirectoryEntries(raw []interface{}) []DirectoryEntry

ParseDirectoryEntries parses the raw interface{} slice produced by json.Unmarshal into map[string]interface{} — entries missing external_id are dropped.

type DirectorySyncRequest

type DirectorySyncRequest struct {
	NetworkID uint16           `json:"network_id"`
	Entries   []DirectoryEntry `json:"entries"`
	// If true, nodes whose external_id is not in the entries list will be kicked.
	RemoveUnlisted bool `json:"remove_unlisted,omitempty"`
}

DirectorySyncRequest is the protocol payload for directory sync.

type DirectorySyncResult

type DirectorySyncResult struct {
	Updated  int      `json:"updated"`  // roles updated
	Disabled int      `json:"disabled"` // nodes disabled (kicked)
	Mapped   int      `json:"mapped"`   // entries mapped to existing nodes
	Unmapped int      `json:"unmapped"` // entries with no matching node
	Actions  []string `json:"actions"`
}

DirectorySyncResult describes what the sync operation did.

type Manager

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

Manager handles push-based replication from primary to standbys. Standbys connect to the primary and subscribe; the primary pushes snapshots after every state mutation.

func NewManager

func NewManager() *Manager

NewManager creates a Manager ready to accept subscribers.

func (*Manager) AddSub

func (m *Manager) AddSub(conn net.Conn)

func (*Manager) Push

func (m *Manager) Push(snapJSON []byte)

Push sends a full snapshot to all subscribers. Failed subscribers are removed. Each write is serialized per-connection via connWriter.wmu.

func (*Manager) PushDelta

func (m *Manager) PushDelta(entries []walpkg.DeltaEntry, seqNo uint64)

PushDelta sends delta entries to all subscribers. This is much smaller than a full snapshot. Standbys that fall behind the delta window will be sent a full snapshot on the next Push().

func (*Manager) RemoveSub

func (m *Manager) RemoveSub(conn net.Conn)

func (*Manager) StartHeartbeat

func (m *Manager) StartHeartbeat(done <-chan struct{})

StartHeartbeat sends periodic heartbeat messages to all replication subscribers so standbys can detect primary failure within ~30s. It blocks until done is closed.

func (*Manager) SubCount

func (m *Manager) SubCount() int

Jump to

Keyboard shortcuts

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