utils

package
v0.1.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPodCliqueNameFromPodCliqueFQN

func GetPodCliqueNameFromPodCliqueFQN(pclqObjectMeta metav1.ObjectMeta) (string, error)

GetPodCliqueNameFromPodCliqueFQN extracts the unqualified PodClique name from a fully qualified name.

func GetPodCliqueSetReplicaIndexFromPodCliqueFQN

func GetPodCliqueSetReplicaIndexFromPodCliqueFQN(pcsName, pclqFQNName string) (int, error)

GetPodCliqueSetReplicaIndexFromPodCliqueFQN extracts the PodCliqueSet replica index from a Pod Clique FQN name.

func IsEmptyStringType

func IsEmptyStringType[T ~string](val T) bool

IsEmptyStringType returns true if value (which is a string or has an underline type string) is empty or contains only whitespace characters.

func OnlyOneIsNil

func OnlyOneIsNil[T any](objA, objB *T) bool

OnlyOneIsNil returns true if only one of the Objects is nil else it will return false.

Types

type RunResult

type RunResult struct {
	// SuccessfulTasks are the names of tasks that executed successfully.
	SuccessfulTasks []string
	// FailedTasks are the names of tasks that failed during execution.
	FailedTasks []string
	// SkippedTasks are the names of tasks that were skipped.
	SkippedTasks []string
	// Errors contains all errors encountered during task execution.
	Errors []error
}

RunResult holds the results of running tasks concurrently.

func RunConcurrently

func RunConcurrently(ctx context.Context, logger logr.Logger, tasks []Task) RunResult

RunConcurrently executes a slice of Tasks concurrently.

func RunConcurrentlyWithBounds

func RunConcurrentlyWithBounds(ctx context.Context, logger logr.Logger, tasks []Task, bound int) RunResult

RunConcurrentlyWithBounds executes a slice of Tasks with at most `bound` taskConfigs running concurrently.

func RunConcurrentlyWithSlowStart

func RunConcurrentlyWithSlowStart(ctx context.Context, logger logr.Logger, initialBatchSize int, tasks []Task) RunResult

RunConcurrentlyWithSlowStart executes tasks in exponentially growing batches starting at initialBatchSize. Each successful batch doubles the size of the next batch. On any batch failure, execution halts immediately and remaining tasks are marked as skipped. This prevents overwhelming kube-apiserver with concurrent requests.

func (*RunResult) GetAggregatedError

func (r *RunResult) GetAggregatedError() error

GetAggregatedError returns all task errors joined into a single error.

func (*RunResult) GetSummary

func (r *RunResult) GetSummary() string

GetSummary returns a summary of successful, failed, and skipped tasks.

func (*RunResult) HasErrors

func (r *RunResult) HasErrors() bool

HasErrors returns true if any tasks encountered errors.

type Task

type Task struct {
	// Name is the name of the task, used for logging and result reporting.
	Name string
	// Fn is the function that will be executed.
	Fn func(ctx context.Context) error
}

Task is a named closure.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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