system

package
v0.0.0-pr80 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func SetupLogging()

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 {
	CommandContext context.Context
	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 Service

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

type ServiceLogger

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

func NewServiceLogger

func NewServiceLogger(service Service) *ServiceLogger

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{})

Jump to

Keyboard shortcuts

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