notify

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package notify provides a way to send external notifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockTemplate

func MockTemplate(tmplName string) *template.Template

MockTemplate returns parsed text template to be used in Mock notifier, mainly for testing.

Types

type LogsErr

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

LogsErr is a notification client which "sends" notification as logs of severity ERROR. It implements Sender interface. It might be handy to use for local development or in situations when other communications channels are not yet in place.

func NewLogsErr

func NewLogsErr(logger *slog.Logger) *LogsErr

NewLogsErr instantiate new LogsErr for given structured logger.

func (*LogsErr) Send

func (l *LogsErr) Send(_ context.Context, tmpl Template, data MsgData) error

Send sends given message as a log of severity ERROR.

type Mock

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

Mock sends message into a string slice in memory. It implements Sender interface. Useful mostly for testing.

func NewMock

func NewMock(buffor *[]string) *Mock

NewMock initialized Mock for given string slice buffor.

func (*Mock) Send

func (m *Mock) Send(_ context.Context, tmpl Template, data MsgData) error

Send sends a message onto internal Mock buffor.

type MsgData

type MsgData struct {
	DagId        string
	ExecTs       string
	TaskId       *string
	Retry        int
	TaskRunError error
	RuntimeInfo  map[string]any
}

Message contains a DAG run contextual information.

type Sender

type Sender interface {
	Send(context.Context, Template, MsgData) error
}

Sender sends a Message notification. Usually onto an external channel of communication. Template should be already parsed text template which can use additional information from MsgData.

type Template

type Template interface {
	Execute(io.Writer, any) error
}

Template represents a message template. Go standard text/template.Template and html/template.Template satisfy this interface.

Jump to

Keyboard shortcuts

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