Documentation ¶
Index ¶
- Constants
- Variables
- func AbsResolveSymlink(path string) string
- func AllZero(s []byte) bool
- func CeilTimeUpToMicroseconds(timeToCeil time.Time) time.Time
- func ConcatByteSlices(a []byte, b []byte) []byte
- func CreateLocalFile(targetPath, name string) (*os.File, error)
- func CreateParentDirs(fileName string, targetPath string) error
- func FastCopy(dst io.Writer, src io.Reader) (int64, error)
- func GetFileExtension(filePath string) string
- func GetLocalFile(targetPath string, header *tar.Header) (localFile *os.File, isNewFile bool, err error)
- func GetLocalFileInfo(targetPath string) (fileInfo os.FileInfo, err error)
- func GetSubdirectoryRelativePath(subdirectoryPath string, directoryPath string) string
- func IsDirectoryEmpty(directoryPath string) (bool, error)
- func IsInDirectory(path, directoryPath string) bool
- func LoggedClose(c io.Closer, errmsg string)
- func LoggedSync(file *os.File, errmsg string, fsync bool)
- func MarshalEnumToString(enum fmt.Stringer) ([]byte, error)
- func Max(a, b int) int
- func Min(a, b int) int
- func NormalizePath(path string) string
- func ParseUntilTS(untilTS string) (time.Time, error)
- func PathsEqual(path1, path2 string) bool
- func ResetTimer(t *time.Timer, d time.Duration)
- func ResolveSymlink(path string) string
- func SanitizePath(path string) string
- func ScanToMap(rows *sql.Rows, dst map[string]interface{}) error
- func SelectMatchingFiles(fileMask string, filePathsToFilter map[string]bool) (map[string]bool, error)
- func StartCommandWithStdoutPipe(cmd *exec.Cmd) (io.ReadCloser, error)
- func StartCommandWithStdoutStderr(cmd *exec.Cmd) (io.ReadCloser, *bytes.Buffer, error)
- func StripLeftmostBackupName(path string) string
- func StripPrefixName(path string) string
- func StripRightmostBackupName(path string) string
- func StripWalFileName(path string) string
- func TimeNowCrossPlatformLocal() time.Time
- func TimeNowCrossPlatformUTC() time.Time
- func ToBytes(x interface{}) []byte
- func TrimFileExtension(filePath string) string
- func TryFetchTimeRFC3999(name string) (string, bool)
- func WriteLocalFile(fileReader io.Reader, header *tar.Header, localFile *os.File, fsync bool) error
- type BytesPool
- type CascadeReadCloser
- type CascadeWriteCloser
- type CloseOnce
- type Empty
- type EmptyWriteCloserIgnorer
- type EmptyWriteIgnorer
- type ForbiddenActionError
- type SignalHandler
- type WithSizeReadCloser
- type WithSizeReader
Constants ¶
const ( VersionStr = "005" BaseBackupPath = "basebackups_" + VersionStr + "/" CatchupPath = "catchup_" + VersionStr + "/" WalPath = "wal_" + VersionStr + "/" BackupNamePrefix = "base_" BackupTimeFormat = "20060102T150405Z" // timestamps in that format should be lexicographically sorted // utility.SentinelSuffix is a suffix of backup finish sentinel file SentinelSuffix = "_backup_stop_sentinel.json" CompressedBlockMaxSize = 20 << 20 CopiedBlockMaxSize = CompressedBlockMaxSize MetadataFileName = "metadata.json" StreamMetadataFileName = "stream_metadata.json" PathSeparator = string(os.PathSeparator) Mebibyte = 1024 * 1024 )
const CopyBytesPoolSize = 2
Variables ¶
var MaxTime time.Time
MaxTime not really the maximal value, but high enough.
var MinTime = time.Unix(0, 0)
Functions ¶
func AbsResolveSymlink ¶
AbsResolveSymlink first tries to turn 'path' to an absolute path, then calls ResolveSymlink. If 'path' can't be turned to an absolute path, keep the relative path.
func CeilTimeUpToMicroseconds ¶
This function is needed for being cross-platform
func ConcatByteSlices ¶
func CreateLocalFile ¶
create new local file on disk
func CreateParentDirs ¶
creates parent dirs of the file
func GetFileExtension ¶
func GetLocalFile ¶
func GetLocalFileInfo ¶
get file info by file path
func IsDirectoryEmpty ¶
func IsInDirectory ¶
func LoggedClose ¶
func MarshalEnumToString ¶
MarshalEnumToString is used to write the string enum representation instead of int enum value to JSON
func NormalizePath ¶
func PathsEqual ¶
func ResetTimer ¶
ResetTimer safety resets timer (drains channel if required)
func ResolveSymlink ¶
utility.ResolveSymlink converts path to physical if it is symlink
func SanitizePath ¶
func SelectMatchingFiles ¶
func StartCommandWithStdoutPipe ¶
func StartCommandWithStdoutPipe(cmd *exec.Cmd) (io.ReadCloser, error)
func StripLeftmostBackupName ¶
func StripPrefixName ¶
func TimeNowCrossPlatformUTC ¶
func TrimFileExtension ¶
func TryFetchTimeRFC3999 ¶
Types ¶
type BytesPool ¶
type BytesPool struct {
// contains filtered or unexported fields
}
BytesPool holds []byte.
type CascadeReadCloser ¶
type CascadeReadCloser struct { io.ReadCloser Underlying io.Closer }
CascadeReadCloser bundles multiple closures into one function. Calling Close() will close the main and underlying writers.
func (*CascadeReadCloser) Close ¶
func (cc *CascadeReadCloser) Close() error
Close returns the first encountered error from closing main or underlying writer.
type CascadeWriteCloser ¶
type CascadeWriteCloser struct { io.WriteCloser Underlying io.Closer }
CascadeWriteCloser bundles multiple closures into one function. Calling Close() will close the main and underlying writers.
func (*CascadeWriteCloser) Close ¶
func (cc *CascadeWriteCloser) Close() error
Close returns the first encountered error from closing main or underlying writer.
type CloseOnce ¶
type CloseOnce struct { io.WriteCloser // contains filtered or unexported fields }
CloseOnce is a wrapper that prevents users from closing io.WriteCloser multiple times Note: The behavior of Close after the first call is undefined. (proof: io.Closer comments)
type EmptyWriteCloserIgnorer ¶
type EmptyWriteCloserIgnorer struct {
io.WriteCloser
}
func (EmptyWriteCloserIgnorer) Close ¶
func (e EmptyWriteCloserIgnorer) Close() error
type EmptyWriteIgnorer ¶
EmptyWriteIgnorer handles 0 byte write in LZ4 package to stop pipe reader/writer from blocking.
type ForbiddenActionError ¶
type ForbiddenActionError struct {
// contains filtered or unexported fields
}
func NewForbiddenActionError ¶
func NewForbiddenActionError(message string) ForbiddenActionError
func (ForbiddenActionError) Error ¶
func (err ForbiddenActionError) Error() string
type SignalHandler ¶
type SignalHandler struct {
// contains filtered or unexported fields
}
SignalHandler defines signal handler setup & shutdown representation
func NewSignalHandler ¶
func NewSignalHandler(ctx context.Context, cancel func(), signals []os.Signal) *SignalHandler
NewSignalHandler constructs SignalHandler and sets up signal mask
func (*SignalHandler) Close ¶
func (sh *SignalHandler) Close() error
Close removes signal mask and call cancel func
type WithSizeReadCloser ¶
type WithSizeReadCloser struct { WithSizeReader // contains filtered or unexported fields }
func NewWithSizeReadCloser ¶
func NewWithSizeReadCloser(underlying io.ReadCloser, readSize *int64) *WithSizeReadCloser
func (*WithSizeReadCloser) Close ¶
func (w *WithSizeReadCloser) Close() error
type WithSizeReader ¶
type WithSizeReader struct {
// contains filtered or unexported fields
}
func NewWithSizeReader ¶
func NewWithSizeReader(underlying io.Reader, readSize *int64) *WithSizeReader