utils

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 16 Imported by: 5

Documentation

Overview

Copyright 2025 steadybit GmbH. All rights reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocateExecutable added in v1.3.3

func LocateExecutable(name, envVar string) string

func ReadCpusAllowedCount added in v1.2.18

func ReadCpusAllowedCount(fname string) (int, error)

func RootCommandContext added in v1.4.0

func RootCommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd

func ShortenUUID added in v1.2.17

func ShortenUUID(uuid uuid.UUID) string

Types

type BackgroundState added in v1.4.0

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

func RunCommandInBackground added in v1.4.0

func RunCommandInBackground(cmd *exec.Cmd, logger zerolog.Logger) (*BackgroundState, error)

func (*BackgroundState) Exited added in v1.4.0

func (r *BackgroundState) Exited() (bool, error)

func (*BackgroundState) Wait added in v1.4.0

func (r *BackgroundState) Wait()

type KeyMutex

type KeyMutex interface {
	// Acquires a lock associated with the specified ID, creates the lock if one doesn't already exist.
	LockKey(id string)

	// Releases the lock associated with the specified ID.
	// Returns an error if the specified ID doesn't exist.
	UnlockKey(id string) error
}

KeyMutex is a thread-safe interface for acquiring locks on arbitrary strings.

func NewHashedKeyMutex

func NewHashedKeyMutex(n int) KeyMutex

NewHashedKeyMutex returns a new instance of KeyMutex which hashes arbitrary keys to a fixed set of locks. `n` specifies number of locks, if n <= 0, we use number of cpus. Note that because it uses fixed set of locks, different keys may share same lock, so it's possible to wait on same lock.

Jump to

Keyboard shortcuts

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