hook

package
v0.0.0-...-5fbc178 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Status       string    `json:"status"`
	Labels       KV        `json:"labels"`
	Annotations  KV        `json:"annotations"`
	StartsAt     time.Time `json:"startsAt"`
	EndsAt       time.Time `json:"endsAt"`
	GeneratorURL string    `json:"generatorURL"`
	Fingerprint  string    `json:"fingerprint"`
}

Alert holds one alert for notification templates.

type Alerts

type Alerts []Alert

Alerts is a list of Alert objects.

type Data

type Data struct {
	Receiver string `json:"receiver"`
	Status   string `json:"status"`
	Alerts   Alerts `json:"alerts"`

	GroupLabels       KV `json:"groupLabels"`
	CommonLabels      KV `json:"commonLabels"`
	CommonAnnotations KV `json:"commonAnnotations"`

	ExternalURL string `json:"externalURL"`
}

Data is the data passed to notification templates and webhook pushes.

End-users should not be exposed to Go's type system, as this will confuse them and prevent simple things like simple equality checks to fail. Map everything to float64/string.

type Emitter

type Emitter interface {
	Emit(ctxt context.Context, m Message) error
}

type EmitterFunc

type EmitterFunc func(ctxt context.Context, m Message) error

func (EmitterFunc) Emit

func (e EmitterFunc) Emit(ctxt context.Context, m Message) error

type Hook

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

func NewHook

func NewHook(emitter Emitter, logger zerolog.Logger) Hook

func (Hook) ServeHTTP

func (h Hook) ServeHTTP(w http.ResponseWriter, r *http.Request)

type KV

type KV map[string]string

KV is a set of key/value string pairs.

type Message

type Message struct {
	Data

	// The protocol version.
	Version         string `json:"version"`
	GroupKey        string `json:"groupKey"`
	TruncatedAlerts uint64 `json:"truncatedAlerts"`
}

Message defines the JSON object send to webhook endpoints.

Jump to

Keyboard shortcuts

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