utility

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: Apache-2.0 Imports: 16 Imported by: 11

Documentation

Index

Constants

View Source
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"
	PathSeparator          = string(os.PathSeparator)
	Mebibyte               = 1024 * 1024
)
View Source
const CopyBytesPoolSize = 2

Variables

View Source
var MaxTime time.Time

MaxTime not really the maximal value, but high enough.

View Source
var MinTime = time.Unix(0, 0)

Functions

func AllZero

func AllZero(s []byte) bool

func CeilTimeUpToMicroseconds

func CeilTimeUpToMicroseconds(timeToCeil time.Time) time.Time

This function is needed for being cross-platform

func ConcatByteSlices

func ConcatByteSlices(a []byte, b []byte) []byte

func FastCopy

func FastCopy(dst io.Writer, src io.Reader) (int64, error)

FastCopy copies data from src to dst in blocks of CopiedBlockMaxSize bytes

func GetFileExtension

func GetFileExtension(filePath string) string

func GetSubdirectoryRelativePath added in v0.2.13

func GetSubdirectoryRelativePath(subdirectoryPath string, directoryPath string) string

func IsInDirectory added in v0.2.13

func IsInDirectory(path, directoryPath string) bool

func LoggedClose

func LoggedClose(c io.Closer, errmsg string)

func LoggedSync added in v0.2.20

func LoggedSync(file *os.File, errmsg string)

func MarshalEnumToString added in v0.2.20

func MarshalEnumToString(enum fmt.Stringer) ([]byte, error)

MarshalEnumToString is used to write the string enum representation instead of int enum value to JSON

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func NormalizePath added in v0.2.13

func NormalizePath(path string) string

func ParseUntilTS added in v0.2.22

func ParseUntilTS(untilTS string) (time.Time, error)

func PathsEqual added in v0.2.13

func PathsEqual(path1, path2 string) bool

func ResetTimer added in v0.2.15

func ResetTimer(t *time.Timer, d time.Duration)

ResetTimer safety resets timer (drains channel if required)

func ResolveSymlink(path string) string

utility.ResolveSymlink converts path to physical if it is symlink

func SanitizePath

func SanitizePath(path string) string

func ScanToMap added in v0.2.21

func ScanToMap(rows *sql.Rows, dst map[string]interface{}) error

func SelectMatchingFiles

func SelectMatchingFiles(fileMask string, filePathsToFilter map[string]bool) (map[string]bool, error)

func StartCommandWithStdoutPipe added in v0.2.17

func StartCommandWithStdoutPipe(cmd *exec.Cmd) (io.ReadCloser, error)

func StartCommandWithStdoutStderr added in v0.2.15

func StartCommandWithStdoutStderr(cmd *exec.Cmd) (io.ReadCloser, *bytes.Buffer, error)

func StripLeftmostBackupName added in v0.2.22

func StripLeftmostBackupName(path string) string

func StripPrefixName

func StripPrefixName(path string) string

func StripRightmostBackupName added in v0.2.22

func StripRightmostBackupName(path string) string

func StripWalFileName

func StripWalFileName(path string) string

Strips the backup WAL file name.

func TimeNowCrossPlatformLocal

func TimeNowCrossPlatformLocal() time.Time

func TimeNowCrossPlatformUTC

func TimeNowCrossPlatformUTC() time.Time

func ToBytes

func ToBytes(x interface{}) []byte

func TrimFileExtension

func TrimFileExtension(filePath string) string

func TryFetchTimeRFC3999

func TryFetchTimeRFC3999(name string) (string, bool)

Types

type BytesPool added in v0.2.17

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

BytesPool holds []byte.

func NewBytesPool added in v0.2.17

func NewBytesPool(max int) *BytesPool

NewBytesPool creates new BytesPool.

func (*BytesPool) Get added in v0.2.17

func (p *BytesPool) Get() []byte

Get borrows []byte from the pool.

func (*BytesPool) Put added in v0.2.17

func (p *BytesPool) Put(b []byte)

Put returns []byte to the pool.

type CascadeWriteCloser added in v0.2.20

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 added in v0.2.20

func (cc *CascadeWriteCloser) Close() error

Close returns the first encountered error from closing main or underlying writer.

type Empty

type Empty struct{}

Empty is used for channel signaling.

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 added in v0.2.15

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

SignalHandler defines signal handler setup & shutdown representation

func NewSignalHandler added in v0.2.15

func NewSignalHandler(ctx context.Context, cancel func(), signals []os.Signal) *SignalHandler

NewSignalHandler constructs SignalHandler and sets up signal mask

func (*SignalHandler) Close added in v0.2.15

func (sh *SignalHandler) Close() error

Close removes signal mask and call cancel func

Jump to

Keyboard shortcuts

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