storage

package
v0.0.0-...-16cb735 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

type Monitor struct {
	sync.Mutex
	Id string
	// Statuses is the current status, by the nodes' ids
	Statuses map[string]monitoring.Status
}

Monitor is a monitor for a service

func (*Monitor) SetStatusForNode

func (monitor *Monitor) SetStatusForNode(id string, status monitoring.Status)

SetStatusForNode sets the status for a node by its id

func (*Monitor) Status

func (monitor *Monitor) Status() *MonitorStatus

Status retrieves the current status of the monitored service

type MonitorStatus

type MonitorStatus struct {
	// Statuses are the occurances for each observed status for the monitor
	Statuses map[monitoring.Status]int
}

MonitorStatus is the status of a service, assessed by using all results from all cluster nodes

func (*MonitorStatus) Occurances

func (monitorStatus *MonitorStatus) Occurances(status monitoring.Status) int

Occurances retrieves the number of observed statuses of the given type

type Origin

type Origin struct {
	sync.Mutex
	Id string
	// Services are the services requested for monitoring by the origin, by their id
	Services map[string]*Service
}

Origin is an origin node from which services originate

func (*Origin) AssertService

func (origin *Origin) AssertService(id string) *Service

AssertService retrieves a service by its id and creates it if it does not already exist

func (*Origin) GetService

func (origin *Origin) GetService(id string) (*Service, bool)

GetService retrieves a service by its id

type Service

type Service struct {
	sync.Mutex
	Id string
	// Monitors are the monitors configured for the service, by their id
	Monitors map[string]*Monitor
}

Service is a monitored service

func (*Service) AssertMonitor

func (service *Service) AssertMonitor(id string) *Monitor

AssertMonitor retrieves a monitor by its id and creates it if it does not already exist

func (*Service) GetMonitor

func (service *Service) GetMonitor(id string) (*Monitor, bool)

GetMonitor retrieves a monitor by its id

func (*Service) Status

func (service *Service) Status() monitoring.Status

Status retrieves the current status of the service, taking all monitors into account

type ServiceStatus

type ServiceStatus struct {
}

ServiceStatus is the status of a service, assessed by using all configured monitors

type Store

type Store struct {
	sync.Mutex
	// Origins are all of the origins available in the store, by their id
	Origins map[string]*Origin
}

Store is a central state storage for services and their statuses

func NewStore

func NewStore() *Store

NewStore creates a new store

func (*Store) AssertOrigin

func (store *Store) AssertOrigin(id string) *Origin

AssertOrigin retrieves an origin and creates it if it does not already exist

func (*Store) GetOrigin

func (store *Store) GetOrigin(id string) (*Origin, bool)

GetOrigin retrieves an origin by its id

func (*Store) GetServices

func (store *Store) GetServices() []*Service

GetServices retrieves all configured services

Jump to

Keyboard shortcuts

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