syncer

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package syncer provides SSH/SFTP file synchronization and an explicit remote container restart helper.

Synchronization and restart are intentionally separate. Syncer.Sync uploads files according to SyncConfig and never restarts containers. Callers that need restart behavior must explicitly call RestartContainer after their own application-level decision.

Index

Constants

View Source
const (
	// SyncModeFull completely replaces the remote directory with local files.
	SyncModeFull = "full"

	// SyncModeIncremental uploads only new or modified files.
	SyncModeIncremental = "incremental"
)

Variables

This section is empty.

Functions

func ConnectSSH

func ConnectSSH(host string, port int, user, password string) (*ssh.Client, *sftp.Client, error)

ConnectSSH establishes an SSH connection

func RestartContainer added in v1.0.2

func RestartContainer(sshClient *ssh.Client, config ContainerRestartConfig, logger *logrus.Logger) error

RestartContainer explicitly restarts a remote container using the provided SSH client.

Types

type ContainerRestartConfig added in v1.0.2

type ContainerRestartConfig struct {
	ContainerName string
	Command       string
}

ContainerRestartConfig controls a manually requested container restart.

type FileInfo

type FileInfo struct {
	Path    string
	RelPath string
	Size    int64
	ModTime time.Time
	IsDir   bool
}

FileInfo represents file information for synchronization

type SSHConfig

type SSHConfig struct {
	Host     string
	Port     int
	User     string
	Password string
}

SSHConfig holds SSH connection parameters

type SyncConfig

type SyncConfig struct {
	LocalPath  string
	RemotePath string
	Mode       string
	Workers    int
}

SyncConfig holds synchronization parameters

type Syncer

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

Syncer handles file synchronization

func New

func New(client *sftp.Client, syncConfig SyncConfig, logger *logrus.Logger) *Syncer

New creates a new Syncer instance with direct configuration

func NewWithSSHClient added in v1.0.2

func NewWithSSHClient(sshClient *ssh.Client, client *sftp.Client, syncConfig SyncConfig, logger *logrus.Logger) *Syncer

NewWithSSHClient creates a new Syncer with SSH command execution capabilities.

func (*Syncer) RestartContainer added in v1.0.2

func (s *Syncer) RestartContainer(config ContainerRestartConfig) error

RestartContainer explicitly restarts a remote container using the attached SSH client.

func (*Syncer) SetSSHClient added in v1.0.2

func (s *Syncer) SetSSHClient(sshClient *ssh.Client) *Syncer

SetSSHClient attaches an SSH client to an existing Syncer for remote commands.

func (*Syncer) Sync

func (s *Syncer) Sync() error

Sync performs the file synchronization based on the mode

Jump to

Keyboard shortcuts

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