transfer

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package transfer moves bytes between two Docker engines through the control plane: a volume with rsync, or a database dump piped straight into a restore. Nodes never talk to each other, so every stream is spliced here, over the connections the control plane already holds (the local socket or an agent tunnel). Nothing is encrypted beyond what that transport provides, by design.

Index

Constants

This section is empty.

Variables

View Source
var ErrSameNode = errors.New("transfer: source and target are the same node")

ErrSameNode refuses a copy whose ends are one engine: there is nothing to move, and the target volume would be the source.

Functions

This section is empty.

Types

type Engines

type Engines interface {
	For(serverID uint) (docker.Client, error)
}

Engines resolves a node's Docker client. Satisfied by *nodes.Clients.

type Service

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

Service runs transfers.

func New

func New(engines Engines, syncImage, relayImage func() string) *Service

New builds a transfer service. The image funcs are read per transfer, so an admin override of the catalog applies to the next copy without a restart.

func (*Service) Stream

func (s *Service) Stream(ctx context.Context, producer, consumer StreamEnd, progress func(int64)) (int64, error)

Stream pipes a producer's stdout into a consumer's stdin, with nothing written to disk in between: a database dump flows straight into its restore. It returns the bytes that crossed.

func (*Service) SyncVolume

func (s *Service) SyncVolume(ctx context.Context, src, dst VolumeEnd, opts SyncOptions) (SyncStats, error)

SyncVolume makes dst's volume a copy of src's with one rsync pass. dst must already exist.

The daemon runs next to the source on a throwaway internal network, the client next to the target on another, and the control plane joins the two: a relay dialled into the source network on one side, a relay listening on the target network on the other. The internal networks and a per-pass secret keep workspace containers away from the daemon; that is access control, not encryption.

type StreamEnd

type StreamEnd struct {
	ServerID uint
	Spec     docker.RunSpec
}

StreamEnd is one side of a stream: a one-shot container on a node. The producer writes the data to stdout; the consumer reads it from stdin.

type SyncOptions

type SyncOptions struct {
	// Name makes the helper containers and the sync network unique; one migration item per name.
	Name string
	// Final marks the pass run with every writer stopped. Files that vanish or change mid-copy are
	// expected on a live pass and fatal on the final one, where they would mean a writer is still running.
	Final bool
	// BandwidthKBps caps the copy (rsync --bwlimit), so a live pass does not saturate a node's uplink.
	BandwidthKBps int
	// Progress receives the bytes streamed so far, every few seconds.
	Progress func(streamed int64)
}

SyncOptions tunes one rsync pass.

type SyncStats

type SyncStats struct {
	// Transferred is the size of the files that changed and were sent: the delta a next pass would face.
	Transferred int64 `json:"transferred"`
	// Total is the size of every file in the volume.
	Total int64 `json:"total"`
	// Streamed is the bytes that crossed the control plane, after rsync's delta encoding.
	Streamed int64         `json:"streamed"`
	Duration time.Duration `json:"duration"`
}

SyncStats is what one pass did.

type VolumeEnd

type VolumeEnd struct {
	ServerID uint
	Volume   string
}

VolumeEnd is one side of a volume copy: a Docker volume on a node.

Jump to

Keyboard shortcuts

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