Documentation
¶
Index ¶
- Constants
- func GetPathStatus(ctx context.Context, password *string, sourceRSync string, recursive bool) error
- func GetRsyncVersion() (version string, protocol string, err error)
- func IsCallFailedError(err error) bool
- func IsExtractVersionAndProtocolError(err error) bool
- func IsInstalled() error
- func IsProcessTerminatedError(err error) bool
- func NormalizeRsyncURL(rsyncURL string) string
- func ObtainDirFullSize(ctx context.Context, password *string, dir *core.Dir, retryCount *int, ...) (*core.FolderSize, error)
- func ObtainDirLocalSize(ctx context.Context, password *string, dir *core.Dir, retryCount *int, ...) (*core.FolderSize, error)
- func RunRsyncWithRetry(ctx context.Context, options *Options, log *Logging, stdOut *bytes.Buffer, ...) (sessionErr, retryErr, criticalErr error)
- func WithDefaultParams(params []string) []string
- type CallFailedError
- type ErrorHook
- type ErrorHookCall
- type ExtractVersionAndProtocolError
- type Logging
- type Options
- type ProcessTerminatedError
Constants ¶
const ( MsgRsyncCallFailedError = "RsyncCallFailedError" MsgRsyncProcessTerminatedError = "RsyncProcessTerminatedError" MsgRsyncCannotFindFolderSizeOutputError = "RsyncCannotFindFolderSizeOutputError" MsgRsyncCannotParseFolderSizeOutputError = "RsyncCannotParseFolderSizeOutputError" MsgRsyncExtractVersionAndProtocolError = "RsyncExtractVersionAndProtocolError" )
const RSYNC_APP_CMD = "rsync"
RSYNC_APP_CMD contains RSYNC console utility system name to run.
Variables ¶
This section is empty.
Functions ¶
func GetPathStatus ¶
GetPathStatus verify that RSYNC source path is valid. For this RSYNC is launched, than exit status is evaluated.
func GetRsyncVersion ¶
GetRsyncVersion run RSYNC to get version and protocol.
func IsCallFailedError ¶ added in v0.3.3
IsCallFailedError check that error able to cast to CallFailedError.
func IsExtractVersionAndProtocolError ¶ added in v0.4.0
IsExtractVersionAndProtocolError check that error able to cast to ExtractVersionAndProtocolError.
func IsInstalled ¶
func IsInstalled() error
IsInstalled do verify that RSYNC application present in the system.
func IsProcessTerminatedError ¶ added in v0.3.3
IsProcessTerminatedError check that error able to cast to ProcessTerminatedError.
func NormalizeRsyncURL ¶ added in v0.3.2
NormalizeRsyncURL normalize RSYNC URL by: 1) remove user specification (if found). 2) remove excess '/' chars in path following host.
func ObtainDirFullSize ¶
func ObtainDirFullSize(ctx context.Context, password *string, dir *core.Dir, retryCount *int, rsyncProtocol string, log *Logging) (*core.FolderSize, error)
ObtainDirLocalSize parse STDOUT from RSYNC dry-run execution to extract full size of directory.
func ObtainDirLocalSize ¶
func ObtainDirLocalSize(ctx context.Context, password *string, dir *core.Dir, retryCount *int, rsyncProtocol string, log *Logging) (*core.FolderSize, error)
ObtainDirLocalSize parse STDOUT from RSYNC dry-run execution to extract local size of directory without nested folders.
func RunRsyncWithRetry ¶
func RunRsyncWithRetry(ctx context.Context, options *Options, log *Logging, stdOut *bytes.Buffer, paths core.SrcDstPath) (sessionErr, retryErr, criticalErr error)
RunRsyncWithRetry run RSYNC utility with retry attempts.
func WithDefaultParams ¶
WithDefaultParams return list of obligatory options for each run of RSYNC utility.
Types ¶
type CallFailedError ¶ added in v0.3.3
CallFailedError denote a situation when RSYNC execution completed with non-zero exit code.
func NewCallFailedError ¶ added in v0.3.3
func NewCallFailedError(exitCode int, stdErr *bytes.Buffer) *CallFailedError
NewCallFailedError creates error object based on ExitCode from RSYNC. Use STDERR variable to extract more human readable error description.
func (*CallFailedError) Error ¶ added in v0.3.3
func (v *CallFailedError) Error() string
type ErrorHook ¶
type ErrorHook struct { Call ErrorHookCall PredictedSize *core.FolderSize }
ErrorHook contains call and predicted size to work around RSYNC issues caused by out of disk space case.
func NewErrorHook ¶ added in v0.3.2
func NewErrorHook(call ErrorHookCall, predictedSize core.FolderSize) *ErrorHook
type ErrorHookCall ¶ added in v0.3.2
type ErrorHookCall func(err error, paths core.SrcDstPath, predictedSize *core.FolderSize, repeated int, retryLeft int) (newRetryLeft int, criticalError error)
ErrorHookCall is a delegate used to work around RSYNC issues caused by out of disk space case.
type ExtractVersionAndProtocolError ¶ added in v0.4.0
type ExtractVersionAndProtocolError struct { }
ExtractVersionAndProtocolError denote a situation when attempt to extract rsync version/protocol has failed, and version and protocol are undefined. This error is not critical (in the main) and should not lead to app failure.
func (*ExtractVersionAndProtocolError) Error ¶ added in v0.4.0
func (v *ExtractVersionAndProtocolError) Error() string
type Logging ¶
type Logging struct { EnableLog bool EnableIntensiveLog bool Log logger.PackageLog }
Logging keep settings whether we need to log RSYNC utility functioning. We can log only RSYNC calls, but also STDOUT output for intensive log.
type Options ¶
Options keep settings for RSYNC call. Settings include: retry count, parameters, ErrorHook object for recover attempt if issue thrown.
func NewOptions ¶
func (*Options) SetAuthPassword ¶ added in v0.3.2
SetAuthPassword set password to use in RSYNC call to get data from authenticated (password protected) RSYNC module. Read option "secrets file" at https://linux.die.net/man/5/rsyncd.conf, which describe how to protect RSYNC data source with password.
func (*Options) SetErrorHook ¶
SetErrorHook define callback function to run, if RESYNC utility exited with error code <> 0. Such callback might suggest issue source and make recommendation to user via UI to resolve the issue before following retry.
func (*Options) SetRetryCount ¶
SetRetryCount set retry count for repeated call in case of error return results (exit code <> 0).
type ProcessTerminatedError ¶ added in v0.3.3
type ProcessTerminatedError struct { }
ProcessTerminatedError denote a situation with termination pending.
func (*ProcessTerminatedError) Error ¶ added in v0.3.3
func (v *ProcessTerminatedError) Error() string