state

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package state contains structures to monitor and update the state of the collector in the package status

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedStatus is the error when the Package status indicates a failure
	ErrFailedStatus = errors.New("package status indicates failure")
)

Functions

This section is empty.

Types

type CollectorMonitor

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

CollectorMonitor implements Monitor interface for monitoring the Collector Package Status file

func (*CollectorMonitor) MonitorForSuccess

func (c *CollectorMonitor) MonitorForSuccess(ctx context.Context, packageName string) error

MonitorForSuccess intermittently checks the package status file for either an install failed or success status. If an InstallFailed status is read this returns ErrFailedStatus error. If the context is canceled the context error will be returned.

func (*CollectorMonitor) SetState

func (c *CollectorMonitor) SetState(packageName string, status protobufs.PackageStatusEnum, statusErr error) error

SetState sets the status on the specified package and saves it to the package status file

type Monitor

type Monitor interface {
	// SetState sets the state for the package.
	// If passed in statusErr is not nil it will record the error as the message
	SetState(packageName string, status protobufs.PackageStatusEnum, statusErr error) error

	// MonitorForSuccess will periodically check the state of the package. It will keep checking until the context is canceled or a failed/success state is detected.
	// It will return an error if status is Failed or if the context times out.
	MonitorForSuccess(ctx context.Context, packageName string) error
}

Monitor allows checking and setting state of active install

func NewCollectorMonitor

func NewCollectorMonitor(logger *zap.Logger, installDir string) (Monitor, error)

NewCollectorMonitor create a new Monitor specifically for the collector

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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