Documentation ¶
Overview ¶
Package notify is an experiment for sending notifications.
Index ¶
Constants ¶
const ( Created = State("CREATED") Running = State("RUNNING") Completed = State("COMPLETED") Canceled = State("CANCELED") Failed = State("FAILED") )
Possible values of State.
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶
RegisterProvider should be invoked by notification implementations to indicate that they handle a specific destination type.
func ValidHandle ¶
ValidHandle returns an error if handle is not an acceptable notification destination handle value.
Types ¶
type AsyncNotifier ¶
type AsyncNotifier struct {
// contains filtered or unexported fields
}
AsyncNotifier is a Notifier that wraps a bunch of other notifiers and sends message asynchronously. The invoking code should call AsyncNotifier.Wait() before exiting.
func NewAsyncNotifier ¶
func NewAsyncNotifier(log lg.Log, dests []Destination) (*AsyncNotifier, error)
NewAsyncNotifier returns a Notifier that sends messages asynchronously to the supplied destination. The invoking code should call AsyncNotifier.Wait() before exiting. TODO: Should take a context.Context param.
func (*AsyncNotifier) Send ¶
func (a *AsyncNotifier) Send(msg Message) error
func (*AsyncNotifier) Wait ¶
func (a *AsyncNotifier) Wait(timeout time.Duration)
type DestType ¶
type DestType string
DestType is the destination type, e.g. "slack", "hipchat", or "email" etc.
type Destination ¶
type Destination struct { Type DestType `yaml:"type" json:"type"` Label string `yaml:"label" json:"label"` Target string `yaml:"target" json:"target"` Credentials string `yaml:"credentials" json:"credentials"` }
Destination is a destination for messages.
func (Destination) String ¶
func (d Destination) String() string
type Job ¶
type Job struct { ID string `yaml:"id" json:"id"` Started *time.Time `yaml:"started,omitempty" json:"started,omitempty"` Ended *time.Time `yaml:"ended,omitempty" json:"ended,omitempty"` // Stmt is the SLQ/SQL statement/query this job is executing. Stmt string `yaml:"stmt" json:"stmt"` State State `yaml:"state" json:"state"` Errors []error `yaml:"errors,omitempty" json:"errors,omitempty"` }
Job represents a single libsq engine workflow instance.
func New ¶
New returns a new Job, with a generated ID, and State set to Created. The Started and Ended fields are both nil.
func (*Job) Fail ¶
Fail sets the job.Ended timestamp, job.State to Failed, and adds the provided errors to job.Errors
type Message ¶
type Message struct { Text string `yaml:"text" json:"text"` Job *Job `yaml:"job,empty" json:"job,omitempty"` }
Message is a notification message, optionally containing a Job that the message is associated with.
func NewJobMessage ¶
NewJobMessage creates a Message indicating the state of the job.
type Provider ¶
type Provider interface { // Destination returns a notification Destination instance from the supplied parameters. Destination(typ DestType, target string, label string, credentials string, labelAvailable func(label string) bool) (*Destination, error) // Notifier returns a Notifier instance for the given destination. Notifier(dest Destination) (Notifier, error) }
Provider is a factory that returns Notifier instances and generates notification Destinations from user parameters.
func ProviderFor ¶
ProviderFor returns a Provider for the specified destination type.