Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) 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) EmitSingle ¶
func (t *TarFileEmitter) EmitSingle(src string, fn EmitFunc) error