utils

package
v0.0.0-...-f3b1aef Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComponentLogger

func ComponentLogger(component string) *slog.Logger

ComponentLogger creates a logger with component attribute

func FindLimit

func FindLimit[T cmp.Ordered](x, y T) T

FindLimit returns the minimum of two ordered values, treating zero values as "no limit". If either value is zero, it returns the non-zero value. If both are non-zero, it returns the minimum.

func FindMemoryLimit

func FindMemoryLimit(x, y string) int64

FindMemoryLimit parses two memory limit strings and returns the effective limit in bytes. It returns the smaller of the two limits, treating empty strings or parse errors as "no limit". This is useful for determining the effective memory limit when both global and local limits exist.

func JobLogger

func JobLogger(jobID string) *slog.Logger

JobLogger creates a logger with job_id attribute

func LoadConfig

func LoadConfig(cfg interface{}) error

LoadConfig loads configuration from environment variables and .env file. It will log warnings if the .env file cannot be loaded, but will not fail since environment variables may be provided directly.

func Logger

func Logger() *slog.Logger

Logger returns the default structured logger

func LoggerWith

func LoggerWith(attrs ...slog.Attr) *slog.Logger

LoggerWith creates a logger with predefined attributes

func ParseMemoryLimit

func ParseMemoryLimit(limit string) (int64, error)

ParseMemoryLimit parses a memory limit string (e.g., "1G", "512M") and returns the value in bytes. Supported units are G/g (gigabytes) and M/m (megabytes).

func SetupLogging

func SetupLogging()

setupLogging configures the logging level based on environment

Types

type ExecutorConfig

type ExecutorConfig struct {
	// Executor is the executor to use for running the jobs (default: docker)
	// Possible values: docker, k8s
	Executor             string `env:"HADES_EXECUTOR,notEmpty" envDefault:"docker"`
	CleanupSharedVolumes bool   `env:"CLEANUP" envDefault:"false"`
}

ExecutorConfig holds job executor configuration.

Jump to

Keyboard shortcuts

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