Documentation ¶
Index ¶
- Constants
- func Exists(path string) bool
- func GetBaseDirectory(paths []string) (string, error)
- func GetBasePath(input, output string) string
- func MkdirAll(path string)
- func MkdirAllWithFilename(path string)
- func MoreRecent(dst, src string) (bool, error)
- func Size(path string) (int64, error)
- type Exec
- type LogEntry
- type Logger
- type ProgressInfo
- type ProxyReader
- type Supervisor
Constants ¶
const ( // ERROR logger severity. ERROR = iota // WARN logger severity. WARN // INFO logger severity. INFO // DEBUG logger severity. DEBUG )
const ( // Bps Bytes per second Bps int = 1 << (10 * (iota)) // KBps Kilo Bytes per second KBps // MBps Mega Bytes per second MBps // GBps Giga Bytes per second GBps )
const ( // StatusAlreadyExist - the destination file exist and is more recent. StatusAlreadyExist = "already exist" // StatusCopied - file is copied. StatusCopied = "copied" // StatusOverwritten - destination file is overwritten due to older timpstamp or different size. StatusOverwritten = "overwritten" // StatusFailed - copy has failed. StatusFailed = "failed" )
Variables ¶
This section is empty.
Functions ¶
func GetBaseDirectory ¶
GetBaseDirectory return the common path of the given paths.
func GetBasePath ¶
GetBasePath returns the identical part of the given two paths.
func MkdirAllWithFilename ¶
func MkdirAllWithFilename(path string)
MkdirAllWithFilename creates all parent directories of the given filepath
func MoreRecent ¶
MoreRecent checks if the dst file is more recent and have the same size of the src file.
Types ¶
type Exec ¶
type Exec struct { From string To string Speed float64 Ready chan struct{} // contains filtered or unexported fields }
An Exec copies files at a given ratelimit.
func NewExecWithContext ¶
NewExecWithContext returns a new Exec with the given ctx.
type Logger ¶
A Logger is an LogEntry centralizer.
func NewLoggerWithContext ¶
NewLoggerWithContext returns a new Logger with the given ctx.
type ProgressInfo ¶
type ProgressInfo struct { Name string Size int64 ProxyReader *ProxyReader Status string }
ProgressInfo handle data for building a progress bar.
type ProxyReader ¶
type ProxyReader struct {
// contains filtered or unexported fields
}
A ProxyReader is proxified reader.
func NewProxyReader ¶
func NewProxyReader(r io.Reader) *ProxyReader
NewProxyReader new proxyed reader.
func (*ProxyReader) Close ¶
func (r *ProxyReader) Close() (err error)
Close the reader when it implements io.Closer
func (*ProxyReader) Read ¶
func (r *ProxyReader) Read(b []byte) (n int, err error)
Read implements io.Reader
func (*ProxyReader) ReadChunk ¶
func (r *ProxyReader) ReadChunk() <-chan int
ReadChunk returns the number of read bytes for a chunk.
type Supervisor ¶
type Supervisor struct { context.Context FilePaths []string Destination string ExecTimeout time.Duration Progress chan ProgressInfo Speed float64 Retries int RetryInterval time.Duration // contains filtered or unexported fields }
A Supervisor is batch copier handler.
func NewSupervisor ¶
func NewSupervisor(paths []string, destination string) (*Supervisor, error)
NewSupervisor returns a new Supervisor.
func (*Supervisor) Execute ¶
func (s *Supervisor) Execute() error
Execute runs the Supervisor copy batch.
func (*Supervisor) Logger ¶
func (s *Supervisor) Logger() *Logger
Logger returns the Supervisor logger.
func (*Supervisor) Summary ¶
func (s *Supervisor) Summary() map[string]int
Summary returns the summary of an execution.