maintenancestate

package
v1.3.2 Latest Latest
Warning

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

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

Documentation

Overview

Package maintenancestate provides all the structures and methods necessary to keep track of what is and isn't in maintenance mode, and to save and load that information from disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action describes what the maintenance exporter can do to a site or machine.

const (
	// EnterMaintenance puts a machine or site into maintenance mode.
	EnterMaintenance Action = 2
	// LeaveMaintenance takes a machine or site out of maintenance mode.
	LeaveMaintenance Action = 1
)

func (Action) StatusValue

func (a Action) StatusValue() float64

StatusValue converts the int underlying the Action into a float64 suitable for assigning to a gague metric. When a site or machine is in maintenance mode, the value assigned to the gauge is 1, and when it is not, the value is 0.

type MaintenanceState

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

MaintenanceState is a struct for storing both machine and site maintenance states.

func New

func New(filename string, project string) (*MaintenanceState, error)

New creates a MaintenanceState based on the passed-in filename. If it can't be restored from disk, it also generates an error.

func (*MaintenanceState) CloseIssue

func (ms *MaintenanceState) CloseIssue(issue string, project string) int

CloseIssue removes any machines and sites from maintenance mode when the issue that added them to maintenance mode is closed. The return value is the number of modifications that were made to the machine and site maintenance state.

func (*MaintenanceState) Restore

func (ms *MaintenanceState) Restore(project string) error

Restore the maintenance state from disk.

func (*MaintenanceState) UpdateMachine

func (ms *MaintenanceState) UpdateMachine(machine string, action Action, issue string, project string) int

UpdateMachine causes a single machine to enter or exit maintenance mode.

func (*MaintenanceState) UpdateSite

func (ms *MaintenanceState) UpdateSite(site string, action Action, issue string, project string) int

UpdateSite causes a whole site to enter or exit maintenance mode.

func (*MaintenanceState) Write

func (ms *MaintenanceState) Write() error

Write serializes the content of a maintenanceState object into JSON and writes it to a file on disk.

Jump to

Keyboard shortcuts

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