internal

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StaticFS embed.FS

Functions

func Notify added in v0.4.8

func Notify(heartbeatName string, status Status) func()

Notify returns a function that can be used to send notifications

func ProcessHeartbeatsSettings added in v0.4.8

func ProcessHeartbeatsSettings() error

ProcessHeartbeatsSettings checks if all heartbeats are valid and can be parsed

func ProcessServiceSettings

func ProcessServiceSettings() error

ProcessNotificationSettings checks if all services are valid and can be parsed

func ReadConfigFile

func ReadConfigFile(configPath string, init bool) error

ReadConfigFile reads the notifications config file configPath is the path to the config file init is true if the config file is read on startup. this will skip the comparison of the previous config

func ResetTimerIfRunning

func ResetTimerIfRunning(previousHeartbeats *[]Heartbeat)

ResetTimerIfRunning resets existing timers if they are running

Types

type Cache added in v0.4.8

type Cache struct {
	MaxSize int `mapstructure:"maxSize"`
	Reduce  int `mapstructure:"reduce"`
}

Cache holds the configuration for the cache

type Config

type Config struct {
	Path    string `mapstructure:"path"`
	Logging string `mapstructure:"logging"`
}

Config config holds general configuration

type Defaults

type Defaults struct {
	Subject      string `mapstructure:"subject"`
	Message      string `mapstructure:"message"`
	SendResolved *bool  `mapstructure:"sendResolved"`
}

Details details holds defaults for notifications

type Heartbeat

type Heartbeat struct {
	Name             string             `mapstructure:"name"`
	UUID             string             `mapstructure:"uuid,omitempty"`
	Enabled          *bool              `mapstructure:"enabled"`
	Description      string             `mapstructure:"description"`
	Interval         time.Duration      `mapstructure:"interval"`
	Grace            time.Duration      `mapstructure:"grace"`
	LastPing         time.Time          `mapstructure:"lastPing"`
	Status           string             `mapstructure:"status"`
	Notifications    []string           `mapstructure:"notifications"`
	NotificationsMap []NotificationsMap `mapstructure:",-,omitempty"`
	IntervalTimer    *timer.Timer       `mapstructure:"intervalTimer,omitempty"`
	GraceTimer       *timer.Timer       `mapstructure:"graceTimer,omitempty"`
}

Heartbeat is a struct for a heartbeat

func (*Heartbeat) GotPing

func (h *Heartbeat) GotPing(details map[string]string)

GotPing starts the timer for the heartbeat (heartbeatName)

func (*Heartbeat) GotPingFail added in v0.2.5

func (h *Heartbeat) GotPingFail(details map[string]string)

GotPingFail stops the timer for the heartbeat

func (*Heartbeat) TimeAgo

func (h *Heartbeat) TimeAgo(t time.Time) string

TimeAgo returns a string with the time since the last ping

type Heartbeats added in v0.3.0

type Heartbeats struct {
	Version       string        `mapstructure:"version"`
	Config        Config        `mapstructure:"config"`
	Server        Server        `mapstructure:"server"`
	Cache         Cache         `mapstructure:"cache"`
	Heartbeats    []Heartbeat   `mapstructure:"heartbeats"`
	Notifications Notifications `mapstructure:"notifications"`
}

Heartbeats is the main configuration struct

var ConfigCopy Heartbeats
var HeartbeatsServer Heartbeats

func (*Heartbeats) GetHeartbeatByName added in v0.3.0

func (h *Heartbeats) GetHeartbeatByName(name string) (*Heartbeat, error)

GetHeartbeatByName search heartbeat in HeartbeatsConfig.Heartbeats by name and returns it

func (*Heartbeats) GetHeartbeatByUUID added in v0.4.8

func (h *Heartbeats) GetHeartbeatByUUID(uuid string) (*Heartbeat, error)

GetHeartbeatByUUID search heartbeat in HeartbeatsConfig.Heartbeats by uuid and returns it

func (*Heartbeats) GetServiceByName added in v0.3.0

func (h *Heartbeats) GetServiceByName(notificationType string) (*Service, error)

GetServiceByType returns notification settings by type

type Notifications

type Notifications struct {
	Defaults Defaults  `mapstructure:"defaults"`
	Services []Service `mapstructure:"services"`
}

NotifyConfig holds the configuration for the notifications

type NotificationsMap added in v0.4.8

type NotificationsMap struct {
	Name    string `mapstructure:"name"`
	Type    string `mapstructure:"type"`
	Enabled bool   `mapstructure:"enabled"`
}

type Server

type Server struct {
	Hostname string `mapstructure:"hostname"`
	Port     int    `mapstructure:"port"`
	SiteRoot string `mapstructure:"siteRoot"`
}

Server is the holds HTTP server settings

type Service added in v0.4.8

type Service struct {
	Name         string `mapstructure:"name"`
	Enabled      *bool  `mapstructure:"enabled,omitempty"`
	SendResolved *bool  `mapstructure:"sendResolved,omitempty"`
	Message      string `mapstructure:"message,omitempty"`
	Shoutrrr     string `mapstructure:"shoutrrr"`
}

Service represents a notification service

type Status added in v0.2.5

type Status int16

Enum for Status

const (
	OK Status = iota
	GRACE
	FAILED
	AGAIN
)

Enum values for Status

func (Status) String added in v0.2.5

func (s Status) String() string

String returns the string representation of the Status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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