transfer

package
v1.11.9 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package transfer handles all logic related to transferring servers between two nodes. This includes the logic for archiving a server on the source node and logic for importing a server from the source node into the target node.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

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

Archive represents an archive used to transfer the contents of a server.

func NewArchive

func NewArchive(t *Transfer, size uint64) *Archive

NewArchive returns a new archive associated with the given transfer.

func (*Archive) Progress

func (a *Archive) Progress() *progress.Progress

Progress returns the current progress of the archive.

func (*Archive) Stream

func (a *Archive) Stream(ctx context.Context, w io.Writer) error

Stream returns a reader that can be used to stream the contents of the archive.

type Manager

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

Manager manages transfers.

func Incoming

func Incoming() *Manager

Incoming returns a transfer manager for incoming transfers.

func NewManager

func NewManager() *Manager

NewManager returns a new transfer manager.

func Outgoing

func Outgoing() *Manager

Outgoing returns a transfer manager for outgoing transfers.

func (*Manager) Add

func (m *Manager) Add(transfer *Transfer)

Add adds a transfer to the manager.

func (*Manager) Get

func (m *Manager) Get(id string) *Transfer

Get gets a transfer from the manager using a server ID.

func (*Manager) Remove

func (m *Manager) Remove(transfer *Transfer)

Remove removes a transfer from the manager.

type Status

type Status string

Status represents the current status of a transfer.

const (
	// StatusPending is the status of a transfer when it is first created.
	StatusPending Status = "pending"
	// StatusProcessing is the status of a transfer when it is currently in
	// progress, such as when the archive is being streamed to the target node.
	StatusProcessing Status = "processing"

	// StatusCancelling is the status of a transfer when it is in the process of
	// being cancelled.
	StatusCancelling Status = "cancelling"

	// StatusCancelled is the final status of a transfer when it has been
	// cancelled.
	StatusCancelled Status = "cancelled"
	// StatusFailed is the final status of a transfer when it has failed.
	StatusFailed Status = "failed"
	// StatusCompleted is the final status of a transfer when it has completed.
	StatusCompleted Status = "completed"
)

func (Status) String

func (s Status) String() string

String satisfies the fmt.Stringer interface.

type Transfer

type Transfer struct {

	// Server associated with the transfer.
	Server *server.Server
	// contains filtered or unexported fields
}

Transfer represents a transfer of a server from one node to another.

func New

func New(ctx context.Context, s *server.Server) *Transfer

New returns a new transfer instance for the given server.

func (*Transfer) Archive

func (t *Transfer) Archive() (*Archive, error)

Archive returns an archive that can be used to stream the contents of the contents of a server.

func (*Transfer) Cancel

func (t *Transfer) Cancel()

Cancel cancels the transfer.

func (*Transfer) Context

func (t *Transfer) Context() context.Context

Context returns the context for the transfer.

func (*Transfer) Error

func (t *Transfer) Error(err error, v string)

Error logs an error that occurred on the source node.

func (*Transfer) Log

func (t *Transfer) Log() *log.Entry

Log returns a logger for the transfer.

func (*Transfer) PushArchiveToTarget

func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error)

PushArchiveToTarget POSTs the archive to the target node and returns the response body.

func (*Transfer) SendMessage

func (t *Transfer) SendMessage(v string)

SendMessage sends a message to the server's console.

func (*Transfer) SetStatus

func (t *Transfer) SetStatus(s Status)

SetStatus sets the status of the transfer.

func (*Transfer) Status

func (t *Transfer) Status() Status

Status returns the current status of the transfer.

Jump to

Keyboard shortcuts

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