actions

package
v2.0.0-alpha5+incompat... Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package actions provides Actions implementations and runner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	// ID returns an Action ID.
	ID() string
	// Type returns an Action type.
	Type() string
	// Run runs an Action and returns output and error.
	Run(ctx context.Context) ([]byte, error)
	// contains filtered or unexported methods
}

Action describes an abstract thing that can be run by a client and return some output.

func NewMySQLExplainAction

func NewMySQLExplainAction(id string, params *agentpb.StartActionRequest_MySQLExplainParams) Action

NewMySQLExplainAction creates MySQL Explain Action. This is an Action that can run `EXPLAIN` command on MySQL service with given DSN.

func NewProcessAction

func NewProcessAction(id string, cmd string, arg []string) Action

NewProcessAction creates a new process Action.

Process Action, it's an abstract Action that can run an external commands. This commands can be a shell script, script written on interpreted language, or binary file.

type ActionResult

type ActionResult struct {
	ID     string
	Output []byte
	Error  error
}

ActionResult represents an Action result.

type ConcurrentRunner

type ConcurrentRunner struct {
	// contains filtered or unexported fields
}

ConcurrentRunner represents concurrent Action runner. Action runner is component that can run an Actions.

func NewConcurrentRunner

func NewConcurrentRunner(ctx context.Context, timeout time.Duration) *ConcurrentRunner

NewConcurrentRunner returns new runner. With this component you can run actions concurrently and read action results when they will be finished. If timeout is 0 it sets to default = 10 seconds.

ConcurrentRunner is stopped when context passed to NewConcurrentRunner is canceled. Results are reported via Results() channel which must be read until it is closed.

func (*ConcurrentRunner) Results

func (r *ConcurrentRunner) Results() <-chan ActionResult

Results returns channel with Actions results.

func (*ConcurrentRunner) Start

func (r *ConcurrentRunner) Start(a Action)

Start starts an Action in a separate goroutine.

func (*ConcurrentRunner) Stop

func (r *ConcurrentRunner) Stop(id string)

Stop stops running Action.

Jump to

Keyboard shortcuts

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