Version: v0.7.1 Latest Latest

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

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 6 Imported by: 17




View Source
const (
	// TitleKey is the common key for the title prop
	TitleKey = "title"
	// MessageKey is the common key for the message prop
	MessageKey = "message"


This section is empty.


func ItemsToPlain added in v0.4.0

func ItemsToPlain(items []MessageItem) string

ItemsToPlain joins together the MessageItems' Text using newlines Used implement the rich sender API by redirecting to the plain sender implementation


type ConfigProp added in v0.4.2

type ConfigProp interface {
	SetFromProp(propValue string) error
	GetPropValue() (string, error)

ConfigProp interface is used to de-/serialize structs from/to a string representation

type ConfigQueryResolver

type ConfigQueryResolver interface {
	Get(string) (string, error)
	Set(string, string) error
	QueryFields() []string

ConfigQueryResolver is the interface used to get/set and list service config query fields

type CustomURLService added in v0.4.0

type CustomURLService interface {
	GetConfigURLFromCustom(customURL *url.URL) (serviceURL *url.URL, err error)

CustomURLService is the interface that needs to be implemented to support custom URLs in services

type EnumFormatter

type EnumFormatter interface {
	Print(e int) string
	Parse(s string) int
	Names() []string

EnumFormatter translate enums between strings and numbers

type Enummer added in v0.5.0

type Enummer interface {
	Enums() map[string]EnumFormatter

Enummer contains fields that have associated EnumFormatter instances

type Field added in v0.4.0

type Field struct {
	Key   string
	Value string

Field is a Key/Value pair used for extra data in log messages

func FieldsFromMap added in v0.4.0

func FieldsFromMap(fieldMap map[string]string, sorted bool) []Field

FieldsFromMap creates a Fields slice from a map, optionally sorting keys

type Generator

type Generator interface {
	Generate(service Service, props map[string]string, args []string) (ServiceConfig, error)

Generator is the interface for tools that generate service configurations from a user dialog

type MessageItem added in v0.4.0

type MessageItem struct {
	Text      string
	Timestamp time.Time
	Level     MessageLevel
	Fields    []Field

MessageItem is an entry in a notification being sent by a service

func (*MessageItem) WithField added in v0.4.0

func (mi *MessageItem) WithField(key, value string) *MessageItem

WithField appends the key/value pair to the message items fields

type MessageLevel added in v0.4.0

type MessageLevel uint8

MessageLevel is used to denote the urgency of a message item

const (
	// Unknown is the default message level
	Unknown MessageLevel = iota
	// Debug is the lowest kind of known message level
	// Info is generally used as the "normal" message level
	// Warning is generally used to denote messages that might be OK, but can cause problems
	// Error is generally used for messages about things that did not go as planned

	// MessageLevelCount is used to create arrays that maps levels to other values
	MessageLevelCount = int(messageLevelCount)

func (MessageLevel) String added in v0.4.0

func (level MessageLevel) String() string

type MessageLimit added in v0.4.0

type MessageLimit struct {
	ChunkSize      int
	TotalChunkSize int

	// Maximum number of chunks (including the last chunk for meta data)
	ChunkCount int

MessageLimit is used for declaring the payload limits for services upstream APIs

type Params

type Params map[string]string

Params is the string map used to provide additional variables to the service templates

func (Params) SetMessage added in v0.5.0

func (p Params) SetMessage(message string)

SetMessage sets the "message" param to the specified value

func (Params) SetTitle added in v0.4.0

func (p Params) SetTitle(title string)

SetTitle sets the "title" param to the specified value

func (Params) Title added in v0.4.0

func (p Params) Title() (title string, found bool)

Title returns the "title" param

type QueuedSender

type QueuedSender interface {
	Enqueuef(format string, v ...interface{})
	Enqueue(message string)
	Flush(params *map[string]string)
	Service() Service

QueuedSender is the interface for a proxied sender that queues messages before sending

type RichSender added in v0.4.0

type RichSender interface {
	SendItems(items []MessageItem, params Params) error

RichSender is the interface needed to implement to send rich notifications

type Sender

type Sender interface {
	Send(message string, params *Params) error

Sender is the interface needed to implement to send notifications

type Service

type Service interface {
	Initialize(serviceURL *url.URL, logger StdLogger) error
	SetLogger(logger StdLogger)

Service is the public common interface for all notification services

type ServiceConfig

type ServiceConfig interface {
	GetURL() *url.URL
	SetURL(*url.URL) error

ServiceConfig is the common interface for all types of service configurations

type ServiceOpts

type ServiceOpts interface {
	Verbose() bool
	Logger() *log.Logger
	Props() map[string]string

ServiceOpts is the interface describing the service options

type StdLogger added in v0.4.3

type StdLogger interface {
	Printf(string, ...interface{})

StdLogger is an interface of a subset of the stdlib log.Logger used for outputting log information from services that are non-fatal

type Templater

type Templater interface {
	GetTemplate(id string) (template *template.Template, found bool)
	SetTemplateString(id string, body string) error
	SetTemplateFile(id string, file string) error

Templater is the interface for the service template API

Jump to

Keyboard shortcuts

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