Documentation
¶
Index ¶
- Constants
- func BinSearchInRange(from, to int, fn func(i int) bool) int
- func ByteToStringUnsafe(b []byte) string
- func CollapseErrors(errs []error) error
- func DeduplicateErrors(errs []error) error
- func DurationToUnit(durationVal time.Duration, unit string) float64
- func EnsureSliceSize[T any](src []T, size int) []T
- func Float64ToPrec(val float64, prec uint32) float64
- func IdxFill(n int) []int
- func IdxShuffle(n int) []int
- func IsCancelled(ctx context.Context) bool
- func MsTsToESFormat(ts uint64) string
- func MustCreateDir(dirPath string)
- func MustFsyncFile(fpath string)
- func MustRemoveFileByPath(fpath string)
- func MustSyncPath(dirPath string)
- func MustWriteFileAtomic(fpath string, data []byte, perm os.FileMode, tmpFileExt string)
- func NsTsToESFormat(ts uint64) string
- func ParseDuration(esDuration string) (time.Duration, error)
- func Recover(metric prometheus.Counter, err error)
- func RecoverToError(panicData any, metric prometheus.Counter) error
- func RemoveFile(file string)
- func RunEvery(done <-chan struct{}, runInterval time.Duration, actionFn func())
- func SizeStr(bytes uint64) string
- func SizeToUnit(sizeVal uint64, unit string) float64
- func StringToByteUnsafe(str string) []byte
- func SyncPath(dirPath string) error
- func VisitFilesWithExt(des []os.DirEntry, ext string, cb func(name string) error) error
- func WriteFileAtomic(fpath string, data []byte, perm os.FileMode, tmpFileExt string) error
- func ZapDurationWithPrec(key string, dur time.Duration, unit string, prec uint32) zap.Field
- func ZapFloat64WithPrec(key string, val float64, prec uint32) zap.Field
- func ZapMsTsAsESTimeStr(key string, ts uint64) zap.Field
- func ZapUint64AsSizeStr(key string, val uint64) zap.Field
- type Bitmask
- type BufferPool
- type ReallocSolver
- type ReallocSolverOpts
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ByteToStringUnsafe ¶
func CollapseErrors ¶
CollapseErrors combines errors and writes repeats of each.
func DeduplicateErrors ¶
DeduplicateErrors deduplicates errors.
func DurationToUnit ¶
DurationToUnit converts duration to unit and returns as float64.
func EnsureSliceSize ¶
func Float64ToPrec ¶
Float64ToPrec formats float64 by removing numberics after prec digit.
func IdxShuffle ¶
func IsCancelled ¶
IsCancelled is a faster way to check if the context has been canceled, compared to ctx.Err() != nil
func MsTsToESFormat ¶
MsTsToESFormat converts timestamp in milliseconds to ES time format string.
func MustCreateDir ¶ added in v0.70.0
func MustCreateDir(dirPath string)
MustCreateDir creates directory at dirPath. Handles the case when directory already exists.
func MustFsyncFile ¶ added in v0.70.0
func MustFsyncFile(fpath string)
func MustRemoveFileByPath ¶ added in v0.60.0
func MustRemoveFileByPath(fpath string)
func MustSyncPath ¶
func MustSyncPath(dirPath string)
func MustWriteFileAtomic ¶ added in v0.70.0
func NsTsToESFormat ¶ added in v0.64.0
NsTsToESFormat converts timestamp in nanoseconds to ES time format string. Nanosecond part will not be printed.
func Recover ¶
func Recover(metric prometheus.Counter, err error)
func RecoverToError ¶
func RecoverToError(panicData any, metric prometheus.Counter) error
func RemoveFile ¶ added in v0.62.3
func RemoveFile(file string)
RemoveFile safely removes a file with logging Handles cases where the file already doesn't exist
func SizeToUnit ¶
SizeToUnit converts size in bytes to unit and returns as float64.
func StringToByteUnsafe ¶
func VisitFilesWithExt ¶ added in v0.70.0
VisitFilesWithExt traverses all the files with `ext` extension in `des` directory and calls a `cb` func for each of files.
func WriteFileAtomic ¶ added in v0.70.0
atomicWrite safely writes data to file using atomic replacement pattern
func ZapDurationWithPrec ¶
ZapDurationWithPrec converts duration to unit and forms float64 zap.Field with removed numerics after prec digit.
func ZapFloat64WithPrec ¶
ZapFloat64WithPrec forms float64 zap.Field with removed numerics after prec digit.
func ZapMsTsAsESTimeStr ¶
ZapMsTsAsESTimeStr converts timestamp in milliseconds to ES time format string and forms string zap.Field.
Types ¶
type Bitmask ¶
type Bitmask struct {
// contains filtered or unexported fields
}
func LoadBitmask ¶
func NewBitmask ¶
func (*Bitmask) GetBitmaskBinary ¶
type BufferPool ¶ added in v0.59.0
type BufferPool struct {
// contains filtered or unexported fields
}
func (*BufferPool) Get ¶ added in v0.59.0
func (q *BufferPool) Get() *bytespool.Buffer
func (*BufferPool) Put ¶ added in v0.59.0
func (q *BufferPool) Put(b *bytespool.Buffer)
type ReallocSolver ¶
type ReallocSolver struct {
// contains filtered or unexported fields
}
func NewReallocSolver ¶
func NewReallocSolver(opts ...ReallocSolverOpts) ReallocSolver
func (*ReallocSolver) ReallocParams ¶
func (s *ReallocSolver) ReallocParams(curLen, curCap int) (int, bool)
type ReallocSolverOpts ¶
type ReallocSolverOpts func(*ReallocSolver)
func ReallocSolverLabel ¶
func ReallocSolverLabel(label string) ReallocSolverOpts