client

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: LGPL-2.1 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheSize   = 1024 * 1024
	DefaultDialTimeout = time.Minute * 3
	DefaultExecTimeout = time.Minute * 10
)
View Source
const (
	SSHClient   = "ssh"
	WinRMClient = "winrm"
	GRPCClient  = "grpc"
)

Variables

View Source
var (
	ErrConnect       = errors.New("connect error")
	ErrInvalidWrite  = errors.New("invalid write result")
	ErrTimeout       = errors.New("request timeout")
	ErrRequest       = errors.New("request exception")
	ErrNotExists     = errors.New("file does not exist")
	ErrAlreadyExists = errors.New("file already exists")
)

Functions

This section is empty.

Types

type ExecOption

type ExecOption func(*ExecOptions)

func ExecWithArgs

func ExecWithArgs(args ...string) ExecOption

func ExecWithEnv

func ExecWithEnv(key, value string) ExecOption

func ExecWithRootDir added in v0.3.8

func ExecWithRootDir(root string) ExecOption

func ExecWithTimeout added in v0.4.3

func ExecWithTimeout(timeout time.Duration) ExecOption

func ExecWithValue

func ExecWithValue(key string, value any) ExecOption

ExecWithValue set key-value at options.Context

type ExecOptions

type ExecOptions struct {
	Context context.Context

	Root         string
	Args         []string
	Environments map[string]string
	Timeout      time.Duration
}

func NewExecOptions

func NewExecOptions() *ExecOptions

type GetOption

type GetOption func(*GetOptions)

func GetWithDir

func GetWithDir(dir bool) GetOption

func GetWithTrace

func GetWithTrace(trace IOTraceFn) GetOption

func GetWithValue

func GetWithValue(key string, value any) GetOption

type GetOptions

type GetOptions struct {
	Context context.Context

	Dir       bool
	CacheSize int64
	Trace     IOTraceFn
}

func NewGetOptions

func NewGetOptions() *GetOptions

type IClient

type IClient interface {
	Name() string
	Stat(ctx context.Context, name string) (*Stat, error)
	// ReadFile reads file content from remote connection
	ReadFile(ctx context.Context, name string) ([]byte, error)
	// Get gets io.ReadCloser from remote connection
	Get(ctx context.Context, src, dst string, opts ...GetOption) error
	// Put uploads local file to remote host
	Put(ctx context.Context, src, dst string, opts ...PutOption) error
	// Execute executes a given command on remote host
	Execute(ctx context.Context, shell string, opts ...ExecOption) (ICmd, error)
	// Close closes all remote connections
	Close() error
}

type ICmd

type ICmd interface {
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.Reader, error)
	StderrPipe() (io.Reader, error)
	Start() error
	Wait() error
	Run() error
	CombinedOutput() ([]byte, error)
	Close() error
}

type IOTrace

type IOTrace struct {
	Name  string
	Src   string
	Dst   string
	Total int64
	Chunk int64
	Speed int64
}

type IOTraceFn

type IOTraceFn func(*IOTrace)

type PutOption

type PutOption func(*PutOptions)

func PutWithDir

func PutWithDir(dir bool) PutOption

func PutWithMkdir

func PutWithMkdir(mkdir bool) PutOption

func PutWithTrace

func PutWithTrace(trace IOTraceFn) PutOption

func PutWithValue

func PutWithValue(key string, value any) PutOption

type PutOptions

type PutOptions struct {
	Context context.Context

	Dir       bool
	Mkdir     bool
	CacheSize int64
	Trace     IOTraceFn
}

func NewPutOptions

func NewPutOptions() *PutOptions

type Stat

type Stat struct {
	Name    string
	IsDir   bool
	Mod     os.FileMode
	ModTime time.Time
	Size    int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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