notifications

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(name string, config Config) (*Client, error)

func (*Client) ProcessEvent

func (c *Client) ProcessEvent(ctx context.Context, event Marshaler) error

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, entities <-chan any) error

Stream consumes the items from the given `entities` chan and triggers a notifications event for each of them.

type Config

type Config struct {
	// If URL is the empty string, notifications are disabled.
	Url              string `yaml:"url" env:"URL"`
	Username         string `yaml:"username" env:"USERNAME"`
	Password         string `yaml:"password" env:"PASSWORD"`
	KubernetesWebUrl string `yaml:"kubernetes_web_url" env:"KUBERNETES_WEB_URL" default:"http://localhost/icingaweb2/kubernetes"`
}

func (*Config) Validate

func (c *Config) Validate() error

Validate checks constraints in the supplied configuration and returns an error if they are violated.

type Event

type Event struct {
	Name      string
	Severity  string
	Message   string
	URL       *url.URL
	Tags      map[string]string
	ExtraTags map[string]string
}

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

type Marshaler

type Marshaler interface {
	MarshalEvent() (Event, error)
}

Marshaler is the interface implemented by types that can marshal themselves into valid notification events.

Jump to

Keyboard shortcuts

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