status

package
v0.0.0-...-d0a9a3c Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusMsg

func StatusMsg(o string, t StatusType, msg string) string

StatusMsg creates the reported status message based on the provided operation type and the given message string.

A message will be generated for empty string. For error status, pass the error message.

Types

type Cmd

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

type CmdFunc

type CmdFunc func() (message string, err error)

type FormattedMessage

type FormattedMessage struct {
	Lang    string `json:"lang"`
	Message string `json:"message"`
}

FormattedMessage is a struct used for serializing status

type Status

type Status struct {
	Operation        string           `json:"operation"`
	Status           StatusType       `json:"status"`
	FormattedMessage FormattedMessage `json:"formattedMessage"`
}

Status is used for serializing status in a manner the server understands

type StatusItem

type StatusItem struct {
	Version      int    `json:"version"`
	TimestampUTC string `json:"timestampUTC"`
	Status       Status `json:"status"`
}

StatusItem is used to serialize an individual part of the status read by the server

type StatusReport

type StatusReport []StatusItem

StatusReport contains one or more status items and is the parent object

func New

func New(t StatusType, operation string, message string) StatusReport

New creates a new Status instance

func (StatusReport) Save

func (r StatusReport) Save(statusFolder string, seqNo uint) error

Save persists the status message to the specified status folder using the sequence number. The operation consists of writing to a temporary file in the same folder and moving it to the final destination for atomicity.

type StatusType

type StatusType string
const (
	// StatusTransitioning indicates the operation has begun but not yet completed
	StatusTransitioning StatusType = "transitioning"

	// StatusError indicates the operation failed
	StatusError StatusType = "error"

	// StatusSuccess indicates the operation succeeded
	StatusSuccess StatusType = "success"
)

Jump to

Keyboard shortcuts

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