trigger

package
v1.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 5 Imported by: 29

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) Shutdown

func (t *Trigger) Shutdown()

Shutdown stops the trigger mechanism

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

func (t *Trigger) TriggerWithReason(reason string)

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.

Jump to

Keyboard shortcuts

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