remote

package
v0.0.0-...-81c1a03 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package remote contains helpers for network operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrClientClosed = errors.New("client is closed")

ErrClientClosed signals that Close was called, so no new operations could be started.

Functions

func Idempotent

func Idempotent(ctx context.Context, fun func() error) error

Idempotent retries an idempotent function until it succeeds or returns a non-retriable error. If the context is cancelled, the function will return during a back-off.

func IsRetriable

func IsRetriable(err error) bool

Returns whether it makes sense to retry on this kind of error.

Types

type CloseableSFTPClient

type CloseableSFTPClient interface {
	SFTPClient

	// Close releases resources used by this client.
	Close() error
}

A CloseableSFTPClient can, in addition to SFTPClient operations, also be closed cleanly.

type ReconnectingSFTPClient

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

A ReconnectingSFTPClient will reconnect if a disconnect happens, but will not do retries on its own.

func NewReconnectingSFTPClient

func NewReconnectingSFTPClient(dialer func() (CloseableSFTPClient, error)) (*ReconnectingSFTPClient, error)

NewReconnectingSFTPClient creates a new client using the given dialer. An error is returned if the dialer couldn't create an initial client.

func (*ReconnectingSFTPClient) Chmod

func (c *ReconnectingSFTPClient) Chmod(path string, mode os.FileMode) error

func (*ReconnectingSFTPClient) Chown

func (c *ReconnectingSFTPClient) Chown(path string, uid, gid int) error

func (*ReconnectingSFTPClient) Chtimes

func (c *ReconnectingSFTPClient) Chtimes(path string, atime time.Time, mtime time.Time) error

func (*ReconnectingSFTPClient) Close

func (c *ReconnectingSFTPClient) Close() error

Close closes the open client, and makes new operations fail with ErrClientClosed.

func (*ReconnectingSFTPClient) Create

func (c *ReconnectingSFTPClient) Create(path string) (f *sftp.File, err error)
func (c *ReconnectingSFTPClient) Link(oldname, newname string) error

func (*ReconnectingSFTPClient) Lstat

func (c *ReconnectingSFTPClient) Lstat(path string) (fi os.FileInfo, err error)

func (*ReconnectingSFTPClient) Mkdir

func (c *ReconnectingSFTPClient) Mkdir(path string) error

func (*ReconnectingSFTPClient) Open

func (c *ReconnectingSFTPClient) Open(path string) (f *sftp.File, err error)

func (*ReconnectingSFTPClient) PosixRename

func (c *ReconnectingSFTPClient) PosixRename(oldname, newname string) error

func (*ReconnectingSFTPClient) ReadDir

func (c *ReconnectingSFTPClient) ReadDir(path string) (fis []os.FileInfo, err error)
func (c *ReconnectingSFTPClient) ReadLink(path string) (s string, err error)

func (*ReconnectingSFTPClient) Remove

func (c *ReconnectingSFTPClient) Remove(path string) error

func (*ReconnectingSFTPClient) RemoveDirectory

func (c *ReconnectingSFTPClient) RemoveDirectory(path string) error

func (*ReconnectingSFTPClient) StatVFS

func (c *ReconnectingSFTPClient) StatVFS(path string) (st *sftp.StatVFS, err error)
func (c *ReconnectingSFTPClient) Symlink(oldname, newname string) error

type SFTPClient

type SFTPClient interface {
	Chmod(path string, mode os.FileMode) error
	Chown(path string, uid, gid int) error
	Chtimes(path string, atime time.Time, mtime time.Time) error
	Create(path string) (*sftp.File, error)
	Link(oldname, newname string) error
	Lstat(path string) (os.FileInfo, error)
	Mkdir(path string) error
	Open(path string) (*sftp.File, error)
	PosixRename(oldname, newname string) error
	ReadDir(path string) ([]os.FileInfo, error)
	ReadLink(path string) (string, error)
	Remove(path string) error
	RemoveDirectory(path string) error
	StatVFS(path string) (*sftp.StatVFS, error)
	Symlink(oldname, newname string) error
}

An SFTPClient abstracts github.com/pkg/sftp.Client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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