notifications

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Integrate different notification services to send notifications about the application status.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ntfy

type Ntfy struct {
	// AccessToken is the access token for the Ntfy service. Required if the Ntfy service requires authentication using access token. Provide the access token in the environment variable NOTIFICATION_NTFY_AUTH_TOKEN.
	AccessToken string `yaml:"-"`
	// ServerEndpoint is the endpoint for the Ntfy service.
	ServerEndpoint string `yaml:"serverEndpoint"`
	// SubscriptionID is the subscription ID for the Ntfy service.
	SubscriptionID string `yaml:"subscriptionID"`
	// UserName is the username for the Ntfy service. Required if the Ntfy service requires authentication using username and password. Provide the password in the environment variable NOTIFICATION_NTFY_PASSWORD.
	UserName string `yaml:"userName"`
	// Password is the password for the Ntfy service. Required if the Ntfy service requires authentication using username and password. Provide the password in the environment variable NOTIFICATION_NTFY_PASSWORD.
	Password string `yaml:"-"`
	// Events is a list of events that the Ntfy service can send notifications for. Supported events are errors, success, or all. Default is errors.
	Events string `yaml:"events" validate:"oneof=errors success all '' "`
}

Ntfy is a struct that contains the configuration for the Ntfy notification service. Visit https://docs.ntfy.sh/ for more information.

func NewNtfy

func NewNtfy() *Ntfy

New returns a new Ntfy struct with default values.

func (*Ntfy) Publish

func (n *Ntfy) Publish(client *http.Client, data []byte, event string) error

Send sends a notification using the Ntfy service with the provided data.

func (*Ntfy) SetUp

func (n *Ntfy) SetUp() error

SetUp sets up the Ntfy service. Environment variables NOTIFICATION_NTFY_PASSWORD and NOTIFICATION_NTFY_AUTH_TOKEN are used to set the password and access token respectively.

type Stdout

type Stdout struct{}

Stdout is a struct that contains the configuration for the sending messages to stdout. Stdout is only used to allow for scenarios where no notification method is provided. By default messages are sent to stdout.

func NewStdout

func NewStdout() *Stdout

Stdout is a struct that contains the configuration for the sending messages to stdout.

func (*Stdout) Publish

func (s *Stdout) Publish(client *http.Client, data []byte, event string) error

func (*Stdout) SetUp

func (s *Stdout) SetUp() error

Jump to

Keyboard shortcuts

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