system

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommitSHA string
View Source
var Version string

Functions

func AddTraceContext

func AddTraceContext(span trace.Span) func(e *zerolog.Event)

Add trace context to a log event

func BoolPointer

func BoolPointer(b bool) *bool

func Debug

func Debug(service Service, title string, data interface{})

func DumpObject

func DumpObject(d interface{})

func DumpObjectDebug

func DumpObjectDebug(d interface{})

func DumpObjectInfo

func DumpObjectInfo(d interface{})

func EnsureDataDir

func EnsureDataDir(path string) (string, error)

func Error

func Error(service Service, title string, err error)

func ExpandTarBuffer

func ExpandTarBuffer(buf *bytes.Buffer, localPath string) error

func GetDataDir

func GetDataDir(path string) string

func GetGPUInfo

func GetGPUInfo() []string

func GetLogger

func GetLogger(service Service) *zerolog.Logger

Get a logger configured with contextual fields

func GetOTelServiceName

func GetOTelServiceName(service Service) string

Convert service names to use standardized OTel underscores

func GetServiceBadge

func GetServiceBadge(service Service) string

func GetServiceString

func GetServiceString(service Service, st string) string

func GetTarBuffer

func GetTarBuffer(localPath string) (*bytes.Buffer, error)

func Info

func Info(service Service, title string, data interface{})

func NewDetachedContext

func NewDetachedContext(parent context.Context) context.Context

NewDetachedContext produces a new context that has a separate cancellation mechanism from its parent. This should be used when having to continue using a context after it has been canceled, such as cleaning up Docker resources after the context has been canceled but want to keep work associated with the same trace.

func RunCommand

func RunCommand(
	name string,
	args []string,
	workingDir string,
) error

func SetupGlobalLogger

func SetupGlobalLogger(service Service, provider *sdklog.LoggerProvider)

Configure the default global logger

func Trace

func Trace(service Service, title string, data interface{})

func WriteFile

func WriteFile(path string, data []byte) error

Types

type CleanupManager

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

CleanupManager provides utilities for ensuring that sub-goroutines can clean up their resources before the main goroutine exits. Can be used to register callbacks for long-running system processes.

func NewCleanupManager

func NewCleanupManager() *CleanupManager

NewCleanupManager returns a new CleanupManager instance.

func (*CleanupManager) Cleanup

func (cm *CleanupManager) Cleanup(ctx context.Context)

Cleanup runs all registered clean-up functions in sub-goroutines and waits for them all to complete before exiting.

func (*CleanupManager) RegisterCallback

func (cm *CleanupManager) RegisterCallback(fn cleanUpWithoutContext)

RegisterCallback registers a clean-up function.

func (*CleanupManager) RegisterCallbackWithContext

func (cm *CleanupManager) RegisterCallbackWithContext(fn cleanUpWithContext)

RegisterCallbackWithContext registers a clean-up function. The context passed is guaranteed not to be already canceled.

type CommandContext

type CommandContext struct {
	Ctx        context.Context
	Cm         *CleanupManager
	CancelFunc context.CancelFunc
}

func NewCommandContext

func NewCommandContext(cmd *cobra.Command) *CommandContext

func NewSystemContext

func NewSystemContext(ctx context.Context) *CommandContext

func NewTestingContext

func NewTestingContext() *CommandContext

func (*CommandContext) Cleanup

func (cmdContext *CommandContext) Cleanup()

type ControlLoop

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

func NewControlLoop

func NewControlLoop(
	service Service,
	ctx context.Context,
	interval time.Duration,
	handler func() error,
) *ControlLoop

func (*ControlLoop) Start

func (loop *ControlLoop) Start(runInitially bool) error

func (*ControlLoop) Trigger

func (loop *ControlLoop) Trigger()

type LogsConfig

type LogsConfig struct {
	Enabled            bool
	URL                string
	Token              string
	ExportBufferSize   int
	ExportInterval     int
	ExportMaxBatchSize int
	ExportTimeout      int
	MaxQueueSize       int
}

type LogsOptions

type LogsOptions struct {
	Enable             bool
	URL                string
	Token              string
	ExportBufferSize   int
	ExportInterval     int
	ExportMaxBatchSize int
	ExportTimeout      int
	MaxQueueSize       int
}

type MetricsConfig

type MetricsConfig struct {
	MetricsURL   string
	MetricsToken string
	Enabled      bool
}

type MetricsOptions

type MetricsOptions struct {
	URL    string `json:"url" toml:"url"`
	Token  string `json:"token" toml:"token"`
	Enable bool
}

type OTelBridge

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

OTelBridge bridges zerolog to OpenTelemetry

func NewOTelBridge

func NewOTelBridge(provider *sdklog.LoggerProvider, service string, consoleWriter zerolog.ConsoleWriter) *OTelBridge

Create a bridge that forwards zerolog logs to OpenTelemetry and writes to a console writer

func (*OTelBridge) Write

func (w *OTelBridge) Write(p []byte) (n int, err error)

Capture zerolog output, write to console, and forward to OpenTelemetry

type Service

type Service string
const (
	SolverService           Service = "solver"
	ResourceProviderService Service = "resource-provider"
	JobCreatorService       Service = "job-creator"
	MediatorService         Service = "mediator"
	Web3Service             Service = "web3"
	DefaultService          Service = "default"
)

type ServiceLogger

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

func NewServiceLogger

func NewServiceLogger(service Service) *ServiceLogger

Get a service logger (deprecated, prefer the GetLogger in new implementations)

func (*ServiceLogger) Debug

func (s *ServiceLogger) Debug(title string, data interface{})

func (*ServiceLogger) Error

func (s *ServiceLogger) Error(title string, err error)

func (*ServiceLogger) Info

func (s *ServiceLogger) Info(title string, data interface{})

func (*ServiceLogger) Trace

func (s *ServiceLogger) Trace(title string, data interface{})

type Telemetry

type Telemetry struct {
	TracerProvider *trace.TracerProvider
	MeterProvider  *metric.MeterProvider
	LoggerProvider *sdklog.LoggerProvider
	Shutdown       func(context.Context) error
}

func SetupOTelSDK

func SetupOTelSDK(ctx context.Context, config TelemetryConfig, metricsConfig MetricsConfig, logsConfig LogsConfig) (telemetry Telemetry, err error)

type TelemetryConfig

type TelemetryConfig struct {
	TelemetryURL   string
	TelemetryToken string
	Enabled        bool
	Service        Service
	Network        string
	Address        string
	GPU            []string
}

type TelemetryOptions

type TelemetryOptions struct {
	URL     string `json:"url" toml:"url"`
	Token   string `json:"token" toml:"token"`
	Disable bool
}

type VersionConfig

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

func NewVersionConfig

func NewVersionConfig(minimumVersion string) (*VersionConfig, error)

func (*VersionConfig) IsSupported

func (vc *VersionConfig) IsSupported(version string) (string, bool)

Jump to

Keyboard shortcuts

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