stateupdater

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreated      = "CREATED"
	StatusQueued       = "QUEUED"
	StatusAssigned     = "ASSIGNED"
	StatusRunning      = "RUNNING"
	StatusTimeout      = "TIMEOUT"
	StatusAborted      = "ABORTED"
	StatusPurging      = "PURGING"
	StatusKilled       = "KILLED"
	StatusFailed       = "FAILED"
	StatusFinished     = "FINISHED"
	StatusMalformed    = "MALFORMED"
	StatusInconclusive = "INCONCLUSIVE"
)

Variables

View Source
var TerminalStatuses = map[string]struct{}{
	StatusFailed:       {},
	StatusFinished:     {},
	StatusInconclusive: {},
	StatusKilled:       {},
	StatusMalformed:    {},
	StatusTimeout:      {},
}

TerminalStatuses contains all the possible statuses of a check that are terminal.

Functions

This section is empty.

Types

type CheckState

type CheckState struct {
	ID       string   `json:"id" validate:"required"`
	Status   *string  `json:"status,omitempty"`
	AgentID  *string  `json:"agent_id,omitempty"`
	Report   *string  `json:"report,omitempty"`
	Raw      *string  `json:"raw,omitempty"`
	Progress *float32 `json:"progress,omitempty"`
}

CheckState defines the all the possible fields of the states sent to the check state queue.

type QueueWriter

type QueueWriter interface {
	Write(body string) error
}

QueueWriter defines the queue services used by and updater to send the status updates.

type Updater

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

Updater takes a CheckState an send its to a queue using the defined queue writer.

func New

func New(qw QueueWriter) *Updater

New creates a new updater using the provided queue writer.

func (*Updater) CheckStatusTerminal

func (u *Updater) CheckStatusTerminal(ID string) bool

CheckStatusTerminal returns true if a check with the given ID has sent so far a state update including a status in a terminal state.

func (*Updater) DeleteCheckStatusTerminal

func (u *Updater) DeleteCheckStatusTerminal(ID string)

DeleteCheckStatusTerminal deletes the information about a check that the Updater is storing.

func (*Updater) UpdateState

func (u *Updater) UpdateState(s CheckState) error

UpdateState updates the state of tha check into the underlaying queue.

Jump to

Keyboard shortcuts

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