utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 24 Imported by: 4

Documentation

Index

Constants

View Source
const CgroupRoot = "/sys/fs/cgroup"

CgroupRoot is where the unified cgroup v2 hierarchy is mounted.

Variables

This section is empty.

Functions

func BackoffRetry

func BackoffRetry(ctx context.Context, maxAttempts int, f RetryFunc) error

BackoffRetry runs f up to maxAttempts times, doubling the wait after each failure.

func CgroupPath added in v0.1.1

func CgroupPath(cgroupRoot, procRoot string, pid int) (string, error)

CgroupPath returns the absolute cgroup v2 directory of the process pid.

func CheckHTTP

func CheckHTTP(ctx context.Context, ID, url string, code int, timeout time.Duration) bool

CheckHTTP reports whether url answers with the expected status code; an empty url passes.

func CheckTCP

func CheckTCP(ctx context.Context, ID string, backends []string, timeout time.Duration) bool

CheckTCP reports whether every backend accepts a TCP connection.

func GetDevicePath

func GetDevicePath(major, minor uint64) (string, error)

func GetIP

func GetIP(endpoint string) string

GetIP returns the host of a node endpoint, which is the only address a node record carries.

func LoadConfig

func LoadConfig(configPath string) (*types.Config, error)

LoadConfig loads the agent config from the YAML file at configPath.

func ProcRoot added in v0.1.1

func ProcRoot() string

ProcRoot returns where this agent reads the host's procfs.

func ReplaceNonUtf8

func ReplaceNonUtf8(str string) string

ReplaceNonUtf8 replaces non-utf8 characters in \x format.

func UseLabelAsFilter

func UseLabelAsFilter() bool

func WithTimeout

func WithTimeout(ctx context.Context, timeout time.Duration, f func(ctx2 context.Context))

func WritePid

func WritePid(ctx context.Context, path string)

Types

type DirWatcher added in v0.1.1

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

DirWatcher reports every entry that appears in or goes away from one directory.

func NewDirWatcher added in v0.1.1

func NewDirWatcher(dir string) (*DirWatcher, error)

NewDirWatcher arms an inotify watch on dir, so nothing that happens after it returns is missed.

func (*DirWatcher) Run added in v0.1.1

func (d *DirWatcher) Run(ctx context.Context, notify func(name string, created bool)) error

Run calls notify for every entry that changed, until ctx is done.

type GroupCAS

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

GroupCAS is a set of compare-and-swap locks keyed by string.

func NewGroupCAS

func NewGroupCAS() *GroupCAS

func (*GroupCAS) Acquire

func (g *GroupCAS) Acquire(key string) (free func(), acquired bool)

type HashBackends

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

func NewHashBackends

func NewHashBackends(data []string) *HashBackends

func (*HashBackends) Get

func (s *HashBackends) Get(v string, offset int) string

type RetryFunc

type RetryFunc func() error

RetryFunc is one attempt of a retried operation.

type RetryTask

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

func NewRetryTask

func NewRetryTask(ctx context.Context, maxAttempts int, f RetryFunc) *RetryTask

func (*RetryTask) Run

func (r *RetryTask) Run() error

func (*RetryTask) Stop

func (r *RetryTask) Stop()

Jump to

Keyboard shortcuts

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