notify

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

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

Notifier represents a notifier.

func (*Notifier) Init

func (n *Notifier) Init(ctx context.Context, projectID string, sender string, store TimeStore) error

Init initializes a notifier for use with the given project. It looks up secrets from either a file or Google Storage bucket specified by the <PROJECTID>_SECRETS environment variable. The optional (non-nil) timestore keeps track of notification times, to avoid sending too frequently. For testing, projectID and sender should be empty strings.

func (*Notifier) Send

func (n *Notifier) Send(ctx context.Context, skey int64, kind, recipient, msg string, mins int) error

Send sends an email message to the given recipient, unless the same kind of email was sent to the same recipient recently.

func (*Notifier) SendOps

func (n *Notifier) SendOps(ctx context.Context, skey int64, kind, msg string) error

SendOps sends an email to the email address defined by the OPS_EMAIL environment variable at most every OPS_PERIOD minutes.

type TimeStore

type TimeStore interface {
	Set(int64, string, time.Time) error   // Set a time for a key.
	Get(int64, string) (time.Time, error) // Get a time for a key.
}

TimeStore is an interface for getting and setting notification times.

func NewTimeStore

func NewTimeStore(store datastore.Store) TimeStore

NewTimeStore returns a TimeStore that uses a datastore for peristence.

Jump to

Keyboard shortcuts

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