alert

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadLevel represent an error if user provide the incorrect level value
	ErrBadLevel = errors.New("bad level")
)

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Name       string    `json:"name"`
	Level      Level     `json:"level"`
	LastChange time.Time `json:"last_change"`
	Start      time.Time `json:"start"`
	Count      int       `json:"count"`
}

Alert is base struct for store Alert information

func New

func New(name string) *Alert

New creates new Alert

func (*Alert) Marshal

func (a *Alert) Marshal() []byte

Marshal returns JSON view if the Alert

func (*Alert) MarshalLua

func (a *Alert) MarshalLua() *lua.LTable

MarshalLua marshal an Alert to the Lua table

type Alerts

type Alerts []*Alert

Alerts contains slice of alerts

func (Alerts) Marshal

func (a Alerts) Marshal() []byte

Marshal returns JSON view of the alerts slice

type Level

type Level int

Level is the type for describe an Alert Level

const (
	// LevelSuccess is Success Level of an alert
	LevelSuccess Level = 1
	// LevelWarn is Waring Level of an alert
	LevelWarn Level = 2
	// LevelError is Error Level of an alert
	LevelError Level = 3
)

func LevelFromInt

func LevelFromInt(i int) (Level, error)

LevelFromInt returns Level based on provided int or error

func LevelFromString

func LevelFromString(s string) (Level, error)

LevelFromString returns Level based on provided string or error

func (Level) NumString

func (l Level) NumString() string

NumString returns numeric value of the Level as a string

func (Level) String

func (l Level) String() string

String returns string value of the Level

type Options

type Options struct {
	Channels []string          `json:"channels"`
	Quiet    bool              `json:"quiet"`
	Repeat   int               `json:"repeat"`
	Image    string            `json:"image"`
	Fields   map[string]string `json:"fields"`
}

Options represents Alert options

func NewOptions added in v0.8.4

func NewOptions() *Options

Jump to

Keyboard shortcuts

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