emitter

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmitFunc

type EmitFunc func(path string, contents io.Reader)

type FileEmitter

type FileEmitter interface {
	CalculateByteSize(src string) int
	EmitAll(src string, fn EmitFunc) error
	EmitSingle(src string, fn EmitFunc) error
}

A FileEmitter is basically a file downloader, but it doesn't actually download files to the filesystem. Instead, it just emits the file data (name, contents) and it's up to the caller to do something with it.

func NewFileEmitter

func NewFileEmitter(client sftp.Client) FileEmitter

NewFileEmitter is a factory function that returns a FileEmitter. It detects at runtime whether the remote server supports `tar` or not, and returns the appropriate downloader.

type SftpFileEmitter

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

SftpFileEmitter downloads each file individually over SFTP. This is much slower than the TarFileEmitter, but is useful when the remote server doesn't have `tar` installed or otherwise doesn't support it.

func (*SftpFileEmitter) CalculateByteSize

func (s *SftpFileEmitter) CalculateByteSize(src string) int

func (*SftpFileEmitter) EmitAll

func (s *SftpFileEmitter) EmitAll(src string, fn EmitFunc) error

func (*SftpFileEmitter) EmitSingle

func (s *SftpFileEmitter) EmitSingle(src string, fn EmitFunc) error

type TarFileEmitter

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

TarFileEmitter runs `tar` on the remote server as an easy way to "stream" the entire directory at once, instead of opening and closing an SFTP connection for each file. This results in a much faster download, and is the preferred method of downloading files.

func (*TarFileEmitter) CalculateByteSize

func (t *TarFileEmitter) CalculateByteSize(src string) int

func (*TarFileEmitter) EmitAll

func (t *TarFileEmitter) EmitAll(src string, fn EmitFunc) error

func (*TarFileEmitter) EmitSingle

func (t *TarFileEmitter) EmitSingle(src string, fn EmitFunc) error

Jump to

Keyboard shortcuts

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