notifier

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Send(n Notification) error
}

Backend describes an object that can send a notification somewhere

type FakeSlackAPIClient

type FakeSlackAPIClient struct {
	PostFunc func(channel, text string, params slack.PostMessageParameters) (string, string, error)
}

func (*FakeSlackAPIClient) PostMessage

func (fs *FakeSlackAPIClient) PostMessage(channel, text string, params slack.PostMessageParameters) (string, string, error)

type MultiRouter

type MultiRouter struct {
	Backends []Backend
}

MultiRouter is an object that routes notifications to all configured backends

func (*MultiRouter) FanOut

func (mr *MultiRouter) FanOut(n Notification) error

FanOut distributes n to all configured backends concurrently

type Notification

type Notification struct {
	Event    NotificationEvent
	Template models.NotificationTemplate
	Data     models.NotificationData
}

Notification models an event notification

type NotificationEvent

type NotificationEvent int

NotificationEvent models events that trigger notifications

const (
	// CreateEnvironment occurs when an environment is created
	CreateEnvironment NotificationEvent = iota
	// UpdateEnvironment occurs when an environment is updated
	UpdateEnvironment
	// DestroyEnvironment occurs when an environment is destroyed
	DestroyEnvironment
	// Success occurs when a create or update operation succeeds
	Success
	// Failure occurs when a create or update operation fails
	Failure
)

func (NotificationEvent) Key

func (ne NotificationEvent) Key() string

type Router

type Router interface {
	FanOut(n Notification) error
}

Router describes an object that routes notifications

type SlackAPIClient

type SlackAPIClient interface {
	PostMessage(channel, text string, params slack.PostMessageParameters) (string, string, error)
}

SlackAPIClient describes the methods we use on slack.Client

type SlackBackend

type SlackBackend struct {
	Username, IconURL string
	API               SlackAPIClient
	Users, Channels   []string
}

SlackBackend is an object that uses API to send notifications to Users and Channels

func (*SlackBackend) Send

func (sb *SlackBackend) Send(n Notification) error

Send broadcasts n to all configured users/channels

type TerminalBackend

type TerminalBackend struct {
	Output io.Writer
	Margin uint
}

TerminalBackend is a notifier backend that writes to Output

func (*TerminalBackend) Send

func (tb *TerminalBackend) Send(n Notification) error

Send renders n to the terminal with a frame around it

Jump to

Keyboard shortcuts

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