triggers

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(triggers map[string][]Condition) (*service, error)

func StateItemKey

func StateItemKey(trigger string, conditionResult ConditionResult, dest services.Destination) string

Types

type Condition

type Condition struct {
	OncePer     string   `json:"oncePer,omitempty"`
	When        string   `json:"when,omitempty"`
	Description string   `json:"description,omitempty"`
	Send        []string `json:"send,omitempty"`
}

Condition holds expression and template that must be used to create notification is expression is returns true

type ConditionResult

type ConditionResult struct {
	Key       string
	OncePer   string
	Templates []string
	Triggered bool
}

type Service

type Service interface {
	// Executes given trigger name and return result of each condition
	Run(triggerName string, vars map[string]interface{}) ([]ConditionResult, error)
}

type State

type State map[string]int64

State track notification triggers state (already notified/not notified)

func NewState

func NewState(val string) State

func (State) SetAlreadyNotified

func (s State) SetAlreadyNotified(trigger string, result ConditionResult, dest services.Destination, isNotified bool) bool

SetAlreadyNotified set the state of given trigger/destination and return if state has been changed

func (State) Truncate

func (s State) Truncate(maxSize int)

Truncate ensures that state has no more than specified number of items and removes unnecessary items starting from oldest

Jump to

Keyboard shortcuts

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