Documentation ¶
Index ¶
- Variables
- type Action
- type ActionInput
- type Config
- func (c *Config) Add(action ...*Action)
- func (c *Config) Exec(input *ActionInput, name TriggerName) bool
- func (c *Config) Get(name TriggerName) *Action
- func (c *Config) ReloadApp(reason string)
- func (c *Config) Run(ctx context.Context)
- func (c *Config) SetReloadCh(sighup chan os.Signal)
- func (c *Config) Stop(event website.EventType)
- type Services
- type TriggerName
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidApp = fmt.Errorf("invalid application provided")
ErrInvalidApp is returned by triggers when a non-existent app is requested.
var ErrNoChannel = fmt.Errorf("no channel to send request")
ErrNoChannel is returned when the go routine is stopped.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { Name TriggerName Fn func(context.Context, *ActionInput) // most actions use this for triggers. C chan *ActionInput // if provided, T is optional. T *time.Ticker // if provided, C is optional. Hide bool // prevent logging. }
Action defines a trigger/timer that can be executed.
type ActionInput ¶ added in v0.4.1
ActionInput is used to send data to a trigger action.
type Config ¶
type Config struct { CIC *clientinfo.Config *website.Server // send trigger responses to website. Snapshot *snapshot.Config Apps *apps.Apps mnd.Logger Services // for running service checks. // contains filtered or unexported fields }
Config is the input data shared by most triggers. Everything is mandatory.
func (*Config) Add ¶
Add adds a new action to our list of "Actions to run." actions are timers or triggers, or both.
func (*Config) Exec ¶
func (c *Config) Exec(input *ActionInput, name TriggerName) bool
Exec runs a trigger. This is abastraction method used in a bunch of places.
func (*Config) Get ¶
func (c *Config) Get(name TriggerName) *Action
Get a trigger by unique name. May return nil, and that could cause a panic. We avoid panics by using a custom type with corresponding constants as input.
func (*Config) Run ¶
Run converts all the tickers and triggers into []reflect.SelectCase. This allows us to run a loop with a dynamic number of channels and tickers to watch.
func (*Config) SetReloadCh ¶ added in v0.4.1
SetReloadCh is ued to set the reload channel for triggers. This is an exported method because the channel is not always available when triggers are initialized.
type Services ¶ added in v0.4.1
Services is the input interface to do things with services via triggers.
type TriggerName ¶
type TriggerName string
TriggerName makes sure triggers have a known name.
const TrigStop TriggerName = "Stopping all triggers and timers (reload)."
TrigStop is used to signal a stop/reload.
func (TriggerName) WithInstance ¶ added in v0.3.3
func (name TriggerName) WithInstance(instance int) TriggerName
WithInstance returns a trigger name with an instance ID.