utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 30 Imported by: 4

Documentation

Index

Constants

This section is empty.

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 CheckHTTP

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

CheckHTTP reports whether every backend answers with the expected status code.

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 GetAppInfo

func GetAppInfo(containerName string) (name, entrypoint, ident string, err error)

func GetDevicePath

func GetDevicePath(_, _ uint64) (string, error)

func GetIP

func GetIP(daemonHost string) string

func GetMaxAttemptsByTTL

func GetMaxAttemptsByTTL(ttl int64) int

func IsDockerized

func IsDockerized() bool

func LoadConfig

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

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

func MakeDockerClient

func MakeDockerClient(config *types.Config) (*engineapi.Client, error)

func MakeYavirtClient

func MakeYavirtClient(config *types.Config) (yavirtclient.Client, error)

func NewBufPipe

func NewBufPipe(bufCap int64) (*PipeReader, *PipeWriter)

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 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

func (*HashBackends) Len

func (s *HashBackends) Len() int

type PipeReader

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

func (*PipeReader) Close

func (r *PipeReader) Close() error

func (*PipeReader) CloseWithError

func (r *PipeReader) CloseWithError(err error) error

CloseWithError closes the reader, later writes on the pipe return err.

func (*PipeReader) Read

func (r *PipeReader) Read(data []byte) (int, error)

type PipeWriter

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

func (*PipeWriter) Close

func (w *PipeWriter) Close() error

func (*PipeWriter) CloseWithError

func (w *PipeWriter) CloseWithError(err error) error

func (*PipeWriter) Write

func (w *PipeWriter) Write(data []byte) (int, error)

Write appends data to the buffer, discarding it once the buffer is over capacity.

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(ctx context.Context) 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