actions

package
v0.0.0-...-d221b79 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name    string      `json:"name"`
	Trigger string      `json:"trigger"`
	If      iff.If      `json:"if"`
	Then    []then.Then `json:"then"`

	Log *zap.SugaredLogger `json:"-"`
	// contains filtered or unexported fields
}

Action represents an action to be executed based on some conditions

func (*Action) Kill

func (a *Action) Kill()

Kill stops the action from ever being ran again.

func (*Action) KillAfter

func (a *Action) KillAfter(n int)

KillAfter kills the action after running n times

func (*Action) Killed

func (a *Action) Killed() bool

Killed returns whether or not the action has been killed

func (*Action) Run

func (a *Action) Run(ctx context.Context)

Run checks the 'ifs' of the action and if they all pass, then it runs the 'thens'

type ActionConfig

type ActionConfig struct {
	Dir     string
	Actions []*Action
}

ActionConfig manages the configuration of actions

func DefaultConfig

func DefaultConfig() *ActionConfig

DefaultConfig returns the default action configuration

func NewActionConfig

func NewActionConfig(dir string) (*ActionConfig, *nerr.E)

NewActionConfig creates a new action manager and starts it

func (*ActionConfig) ActionsByTrigger

func (c *ActionConfig) ActionsByTrigger(ctx echo.Context) error

ActionsByTrigger .

func (*ActionConfig) GetActionsByTrigger

func (c *ActionConfig) GetActionsByTrigger(trigger string) []*Action

GetActionsByTrigger returns all actions with the specified trigger

type ActionManager

type ActionManager struct {
	Config      *ActionConfig
	Workers     int
	EventStream chan events.Event
	EventCache  string
	// contains filtered or unexported fields
}

An ActionManager manages executing a set of actions

func DefaultActionManager

func DefaultActionManager() *ActionManager

DefaultActionManager .

func (*ActionManager) Info

func (a *ActionManager) Info(ctx echo.Context) error

Info .

func (*ActionManager) ManageAction

func (a *ActionManager) ManageAction(action *Action) *nerr.E

ManageAction adds an action to be managed by the action manager currently, an action manager only manages interval and event trigger actions

func (*ActionManager) RunAction

func (a *ActionManager) RunAction(ctx context.Context, action *Action)

RunAction submits an action request to be ran by the action manager

func (*ActionManager) Start

func (a *ActionManager) Start(ctx context.Context) *nerr.E

Start starts the action manager

type ActionRequest

type ActionRequest struct {
	Action  *Action
	Context context.Context
}

ActionRequest is submitted to the action manager to run an action on one of it's worker threads

Directories

Path Synopsis
iff

Jump to

Keyboard shortcuts

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