Documentation
¶
Overview ¶
Package trigger provides a mechanism to trigger actions that require to be serialized while providing a non-blocking notification mechanism
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parameters ¶
type Parameters struct {
// MinInterval is the minimum required interval between invocations of
// TriggerFunc
MinInterval time.Duration
// TriggerFunc is the function to be called when Trigger() is called
// while respecting MinInterval and serialization
TriggerFunc func(reasons []string)
// PrometheusMetrics enables use of a prometheus metric. Name must be set
PrometheusMetrics bool
// Name is the unique name of the trigger. It must be provided in a
// format compatible to be used as prometheus name string.
Name string
// contains filtered or unexported fields
}
Parameters are the user specified parameters
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
Trigger represents an active trigger logic. Use NewTrigger() to create a trigger
func NewTrigger ¶
func NewTrigger(p Parameters) (*Trigger, error)
NewTrigger returns a new trigger based on the provided parameters
func (*Trigger) Trigger ¶
func (t *Trigger) Trigger()
Trigger triggers the call to TriggerFunc as specified in the parameters provided to NewTrigger(). It respects MinInterval and ensures that calls to TriggerFunc are serialized. This function is non-blocking and will return immediately before TriggerFunc is potentially triggered and has completed.
func (*Trigger) TriggerWithReason ¶
Trigger triggers the call to TriggerFunc as specified in the parameters provided to NewTrigger(). It respects MinInterval and ensures that calls to TriggerFunc are serialized. This function is non-blocking and will return immediately before TriggerFunc is potentially triggered and has completed.