ressync

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GroupEndpoints holds what the resource copies, and where to: the
	// source, the destination, and the nodes the copies go to.
	GroupEndpoints = keywords.Group{
		ID:    "endpoints",
		Name:  "Source and target",
		Text:  keywords.NewText(fs, "text/group/endpoints"),
		Order: 10,
	}

	// GroupArray holds the storage array, and its devices or groups, the
	// resource drives the replication or the snapshots of.
	GroupArray = keywords.Group{
		ID:    "array",
		Name:  "Array",
		Text:  keywords.NewText(fs, "text/group/array"),
		Order: 12,
	}

	// GroupSnapshots holds what the resource snapshots, and how.
	GroupSnapshots = keywords.Group{
		ID:    "snapshots",
		Name:  "Snapshots",
		Text:  keywords.NewText(fs, "text/group/snapshots"),
		Order: 20,
	}

	// GroupTransfer holds how an update copies the data.
	GroupTransfer = keywords.Group{
		ID:    "transfer",
		Name:  "Transfer",
		Text:  keywords.NewText(fs, "text/group/transfer"),
		Order: 24,
	}

	// GroupScheduling holds when the resource updates on its own, and
	// whether these updates are logged.
	GroupScheduling = keywords.Group{
		ID:    "scheduling",
		Name:  "Scheduling",
		Text:  keywords.NewText(fs, "text/group/scheduling"),
		Order: 32,
	}

	// GroupStatus holds how old a copy may be before the status of the
	// resource warns.
	GroupStatus = keywords.Group{
		ID:    "status",
		Name:  "Status",
		Text:  keywords.NewText(fs, "text/group/status"),
		Order: 36,
	}

	// GroupRetention holds what the resource keeps of what it made: the
	// snapshots and runs, and the base snapshots kept for a peer missing
	// updates.
	GroupRetention = keywords.Group{
		ID:    "retention",
		Name:  "Retention",
		Text:  keywords.NewText(fs, "text/group/retention"),
		Order: 40,
	}

	// GroupTimeouts holds how long an update may take.
	GroupTimeouts = keywords.Group{
		ID:    "timeouts",
		Name:  "Timeouts",
		Text:  keywords.NewText(fs, "text/group/timeouts"),
		Order: 90,
	}
)

The groups of the keywords several sync drivers have, declared once here and added by each driver whose keywords name them. A group holds, in a driver, the keywords that driver declares with its id: the source of an rsync is a path, the one of a zfs sync a dataset.

The scheduling, status and timeouts groups have the ids, names and orders of the ones of the task drivers, their texts saying the updates of a sync.

View Source
var (
	KWMaxDelay = keywords.Keyword{
		Aliases:       []string{"sync_max_delay"},
		Attr:          "MaxDelay",
		Converter:     converters.Duration,
		DefaultOption: "sync_max_delay",
		Option:        "max_delay",
		Group:         GroupStatus.ID,
		Text:          keywords.NewText(fs, "text/kw/max_delay"),
	}
	KWSchedule = keywords.Keyword{
		Attr:          "Schedule",
		DefaultOption: "sync_schedule",
		Example:       "00:00-01:00 mon",
		Option:        "schedule",
		Group:         GroupScheduling.ID,
		Scopable:      true,
		Text:          keywords.NewText(fs, "text/kw/schedule"),
	}

	KWLog = keywords.Keyword{
		Attr:      "LogRuns",
		Converter: converters.Bool,
		Default:   "false",
		Option:    "log",
		Group:     GroupScheduling.ID,
		Scopable:  true,
		Text:      keywords.NewText(fs, "text/kw/log"),
	}

	BaseKeywords = []*keywords.Keyword{
		&KWLog,
		&KWMaxDelay,
		&KWSchedule,
	}
)

Functions

This section is empty.

Types

type DatasetReplicator

type DatasetReplicator interface {
	RID() string
	ReplicatesDataset(dataset string) bool
	GetMaxDelay(lastSync time.Time) time.Duration
	MaxDelayOrigin() string
}

DatasetReplicator is a sync resource replicating zfs datasets to its peers, as sync.zfs does. It tells the snapshot resources of the object which of their datasets reach the peers, and how fresh the replicas are expected to be.

type Stats

type Stats struct {
	Endpoint      string
	SentBytes     uint64
	ReceivedBytes uint64
	Begin         time.Time
	End           time.Time
}

func NewStats

func NewStats(endpoint string) *Stats

func (*Stats) Close

func (t *Stats) Close()

func (*Stats) Duration

func (t *Stats) Duration() (duration time.Duration)

func (*Stats) SpeedBPS

func (t *Stats) SpeedBPS() (speed float64)

type T

type T struct {
	resource.T
	MaxDelay *time.Duration `json:"max_delay"`
	Schedule string         `json:"schedule"`
	Path     naming.Path    `json:"path"`

	// LogRuns asks the scheduled runs logged, as a run asked by a
	// user is.
	LogRuns bool `json:"log"`

	// ObjectEnv and NodeEnv are the env of the object and of this
	// node, for the drivers whose manifest binds them.
	ObjectEnv string `json:"object_env"`
	NodeEnv   string `json:"node_env"`
}

func (*T) Age

func (t *T) Age(since time.Time) (time.Duration, bool)

Age is how long of writes a copy last synced, or a snapshot taken, at since misses: the time since, or until the writes of the instance stopped when they did, frozen then, as the records of the object say.

func (*T) CopyWithStats

func (t *T) CopyWithStats(ctx context.Context, dst io.Writer, src io.Reader, stats *Stats) (uint64, error)

func (*T) EnvSkipReason

func (t *T) EnvSkipReason() string

EnvSkipReason returns why a sync from this node is skipped, or "" when it is not.

A PRD object running on a node that is not PRD, as on a DRP node after a failover, does not sync: its copies on the PRD nodes are the data to fall back to, which a sync from here would overwrite. The other envs sync wherever they run, as in v2.

func (*T) GetMaxDelay

func (t *T) GetMaxDelay(lastSync time.Time) time.Duration

GetMaxDelay is how long after lastSync the copy is stale: max_delay when set, or else derived from the schedule, 0 meaning neither is.

func (*T) GetTargetNodenames

func (t *T) GetTargetNodenames(target, nodes, drpNodes []string) []string

func (*T) GetTargetPeernames

func (t *T) GetTargetPeernames(target, nodes, drpNodes []string) []string

func (*T) IsInstanceSufficientlyStarted

func (t *T) IsInstanceSufficientlyStarted(ctx context.Context) (bool, string)

IsInstanceSufficientlyStarted reports whether this node holds the instance the data is replicated from, and why not when it does not. See instance.IsReplicationSource for the rules.

A node where its reference resources are not up is a passive one, which must not send: its copy would replace the one of the active node.

func (*T) MaxDelayOrigin

func (t *T) MaxDelayOrigin() string

MaxDelayOrigin says where GetMaxDelay takes its value from, for the messages to say why a copy is stale.

func (*T) PeerEnvRefusal

func (t *T) PeerEnvRefusal(nodename string) error

PeerEnvRefusal returns why the peer nodename is not sent the data of the resource, or nil when it is.

A node that is not PRD sends nothing to a PRD node, whatever the env of the object: its data would overwrite the production one there. It completes the rule of EnvSkipReason, which is about the object, with the one about the nodes.

func (*T) ReceivingNodenames

func (t *T) ReceivingNodenames(target, nodes, drpNodes []string) []string

ReceivingNodenames returns the node a passive instance judges the copy of: this node, when the target makes it a destination, one of nodes with the nodes target, or one of drpNodes with the drpnodes target, and none else. A local target copies on the source alone, and a node the target does not include receives nothing: judged, its copy never synced breached its recovery point objective forever.

func (*T) RunDir

func (t *T) RunDir() runfiles.Dir

RunDir holds a file per sync in progress, as the one of a task: the daemon watches it, and marks the resource and its instance running while a file is there.

func (*T) Running

func (t *T) Running() (resource.RunningInfoList, error)

Running implements resource.Runninger: the syncs in progress, from their run files.

func (*T) SelectPeernames

func (t *T) SelectPeernames(target, configured, nodes, drpNodes []string) ([]string, error)

SelectPeernames is the peers a run asked to sync to target reaches, among the peers of configured, the target of the configuration. An empty target asks all of them. A target is "nodes", "drpnodes", "local", or a node selector expression, so a peer that needs syncing on its own is named.

func (*T) StartRun

func (t *T) StartRun() (func(), error)

StartRun records a sync in progress until the func it returns is called.

func (*T) StatusLastSync

func (t *T) StatusLastSync(nodenames []string, receiving bool) status.T

StatusLastSync judges the freshness of the copies of nodenames. receiving says this node is one of them, a node the data is replicated to, whose copy has a recovery point objective: its max delay.

func (*T) WriteLastSync

func (t *T) WriteLastSync(nodename string) error

func (*T) WritePeerLastSync

func (t *T) WritePeerLastSync(ctx context.Context, peer string) error

WritePeerLastSync records that peer was synced now, and sends it the records it reads: its own last sync, which its status tells the freshness of its copy from, the last syncs of this node and of the other peers, and the last run of the schedule, which keeps its scheduler from syncing again too soon if it becomes the source.

The last syncs of the other peers are what a node that becomes the source tells the freshness of their copies from, until its first sync: a copy is as fresh as the last sync it received, whichever node sent it. v2 sent them all too.

Jump to

Keyboard shortcuts

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