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 ¶
- type Action
- type MaintenanceState
- func (ms *MaintenanceState) CloseIssue(issue string, project string) int
- func (ms *MaintenanceState) Restore(project string) error
- func (ms *MaintenanceState) UpdateMachine(machine string, action Action, issue string, project string) int
- func (ms *MaintenanceState) UpdateSite(site string, action Action, issue string, project string) int
- func (ms *MaintenanceState) Write() error
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.
func (Action) StatusValue ¶
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.