agent

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2017 License: Apache-2.0 Imports: 15 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiRegistry = make(map[string]interface{})
View Source
var PluginRegistry = map[string]Creator{}

Functions

func MapPayload

func MapPayload(name string, event *Event) error

func RandomString

func RandomString(strlen int) string

func RegisterApi

func RegisterApi(i interface{})

func RegisterPlugin

func RegisterPlugin(name string, creator Creator)

func SliceContains

func SliceContains(name string, list []string) bool

Types

type Agent

type Agent struct {
	Queueing   bool
	Events     chan Event
	TestEvents chan Event
	Shutdown   chan struct{}
	Plugins    []*RunningPlugin
}

Agent runs codeflow and collects data based on the given config

func NewAgent

func NewAgent() (*Agent, error)

NewAgent returns an Agent struct based off the given Config

func NewTestAgent

func NewTestAgent(config []byte) (*Agent, error)

NewTestAgent returns an Agent struct based off the given Config

func (*Agent) GetTestEvent

func (a *Agent) GetTestEvent(name string, timeout time.Duration) Event

GetTestEvent listens and returns requested event

func (*Agent) LoadPlugins

func (a *Agent) LoadPlugins() error

func (*Agent) PluginNames

func (a *Agent) PluginNames() []string

Returns a list of strings of the configured plugins.

func (*Agent) Run

func (a *Agent) Run() error

Run runs the agent daemon

func (*Agent) Stop

func (a *Agent) Stop()

Shutdown the agent daemon

type Caller

type Caller struct {
	File       string `json:"file"`
	LineNumber int    `json:"line_number"`
}

type Creator

type Creator func() Plugin

type Event

type Event struct {
	ID           string      `json:"id"`
	ParentID     string      `json:"parentId"`
	Name         string      `json:"name"`
	Payload      interface{} `json:"payload"`
	PayloadModel string      `json:"payloadModel"`
	Error        error       `json:"error"`
	CreatedAt    time.Time   `json:"createdAt"`
	Caller       Caller      `json:"caller"`
}

func NewEvent

func NewEvent(payload interface{}, err error) Event

func (*Event) Dump

func (e *Event) Dump()

func (*Event) NewEvent

func (e *Event) NewEvent(payload interface{}, err error) Event

type Plugin

type Plugin interface {
	// SampleConfig returns the default configuration of the Input
	SampleConfig() string

	// Description returns a one-sentence description on the Input
	Description() string

	// Start starts the Plugin service, whatever that may be
	Start(chan Event) error

	// Stop stops the services and closes any necessary channels and connections
	Stop()

	// Subscribe takes in an event message and validates it for Process
	Subscribe() []string

	// Process takes in an event message and tries to process it
	Process(Event) error
}

type RunningPlugin

type RunningPlugin struct {
	Name    string
	Plugin  Plugin
	Work    func(*workers.Msg)
	Enabled bool
	Workers int
}

Jump to

Keyboard shortcuts

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