target

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package target implements the ways Revere can alert people to problems.

Index

Constants

View Source
const (
	TargetsDir = "targets"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	MonitorID    db.MonitorID
	MonitorName  string
	SubprobeID   db.SubprobeID
	SubprobeName string

	Description string
	Response    string

	OldState state.State
	NewState state.State

	Recorded     time.Time
	EnteredState time.Time
	LastNormal   time.Time

	Details probe.Details

	Host string
}

Alert contains all the information targets can use to construct their alerts.

type Email

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

Email implements a target that alerts people by sending email.

func (*Email) ReplyTo

func (e *Email) ReplyTo() []string

func (*Email) To

func (e *Email) To() []string

func (*Email) Type

func (e *Email) Type() Type

type EmailAddress

type EmailAddress struct {
	To      string
	ReplyTo string
}

type EmailDBModel

type EmailDBModel struct {
	Addresses []struct {
		To      string
		ReplyTo string
	}
}

EmailDBModel defines the JSON serialization format for saving email targets' settings in the database.

type EmailTarget

type EmailTarget struct {
	EmailType
	Addresses []*EmailAddress
}

func (EmailTarget) Serialize

func (et EmailTarget) Serialize() (string, error)

func (EmailTarget) Type

func (EmailTarget) Type() VMType

func (EmailTarget) Validate

func (et EmailTarget) Validate() (errs []string)

type EmailType

type EmailType struct{}

func (EmailType) Id

func (EmailType) Id() db.TargetType

func (EmailType) Name

func (EmailType) Name() string

func (EmailType) Scripts

func (EmailType) Scripts() map[string][]string

func (EmailType) Templates

func (EmailType) Templates() map[string]string

type ErrorAndTriggerIDs

type ErrorAndTriggerIDs struct {
	Err error
	IDs []db.TriggerID
}

type Slack

type Slack struct {
	Channel string
}

func (Slack) Type

func (Slack) Type() Type

type SlackDBModel

type SlackDBModel struct {
	Channel string
}

SlackDBModel defines the JSON serialization format for saving slack targets' settings in the database.

type SlackTarget

type SlackTarget struct {
	SlackType
	Channel string
}

func (SlackTarget) Serialize

func (st SlackTarget) Serialize() (string, error)

func (SlackTarget) Type

func (SlackTarget) Type() VMType

func (SlackTarget) Validate

func (et SlackTarget) Validate() (errs []string)

type SlackType

type SlackType struct{}

func (SlackType) Id

func (SlackType) Id() db.TargetType

func (SlackType) Name

func (SlackType) Name() string

func (SlackType) Scripts

func (SlackType) Scripts() map[string][]string

func (SlackType) Templates

func (SlackType) Templates() map[string]string

type Target

type Target interface {
	Type() Type
}

Target defines a common abstraction for individual targets.

func New

func New(typeID db.TargetType, config types.JSONText) (Target, error)

New makes a Target of the given type and settings.

type Type

type Type interface {
	ID() db.TargetType

	// New returns a new instance of a target of this type.
	New(config types.JSONText) (Target, error)

	// Alert sends alert a to the targets in toAlert.
	//
	// Targets of this type that are also applicable to the alerting
	// subprobe but which shouldn't be alerted (e.g., because they've been
	// alerted too recently or they shouldn't be triggered until a higher
	// level) are included in inactive.
	//
	// Alert returns errors encountered during the sending of alerts,
	// associated with the trigger IDs of the targets that failed with those
	// errors.
	Alert(Db *db.DB, a *Alert, toAlert map[db.TriggerID]Target, inactive []Target) []ErrorAndTriggerIDs
}

Type defines a common abstraction for types of targets.

type VM

type VM interface {
	VMType
	Serialize() (string, error)
	Type() VMType
	Validate() []string
}

func Blank

func Blank(id db.TargetType) (VM, error)

func Default

func Default() VM

func LoadFromDb

func LoadFromDb(id db.TargetType, targetJson string) (VM, error)

func LoadFromParams

func LoadFromParams(id db.TargetType, targetParams string) (VM, error)

type VMType

type VMType interface {
	Id() db.TargetType
	Name() string

	Templates() map[string]string
	Scripts() map[string][]string
	// contains filtered or unexported methods
}

TargetVMType and TargetVM define a common display abstraction for all targets.

func AllTargets

func AllTargets() (tts []VMType)

Jump to

Keyboard shortcuts

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