agent

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetModOptVal

func GetModOptVal(opts map[string]string, key string) string

GetModOptVal gets a module's option value.

func InitializeDefaultModules

func InitializeDefaultModules(
	ctx apitypes.Context,
	config gofig.Config) error

InitializeDefaultModules initializes the default modules.

func Instances

func Instances() <-chan *Instance

Instances returns a channel that receives the instantiated module instances.

func RegisterModule

func RegisterModule(name string, initFunc Init)

RegisterModule registers a module type.

func Start

func Start(
	ctx apitypes.Context,
	config gofig.Config) (apitypes.Context, <-chan error, error)

Start starts the agent.

func StartDefaultModules

func StartDefaultModules(ctx apitypes.Context, config gofig.Config) error

StartDefaultModules starts the default modules.

func StartModule

func StartModule(ctx apitypes.Context, config gofig.Config, name string) error

StartModule starts the module with the provided instance name.

func StopModules

func StopModules(ctx apitypes.Context) error

StopModules stops the modules.

func Types

func Types() <-chan *Type

Types returns a channel that receives the registered module types.

Types

type Config

type Config struct {
	Name        string          `json:"name"`
	Type        string          `json:"type"`
	Description string          `json:"description"`
	Address     string          `json:"address"`
	Config      gofig.Config    `json:"config,omitempty"`
	Client      apitypes.Client `json:"-"`
}

Config is a struct used to configure a module.

type Init

type Init func(ctx apitypes.Context, config *Config) (Module, error)

Init initializes the module.

type Instance

type Instance struct {
	Type        *Type   `json:"-"`
	TypeName    string  `json:"typeName"`
	Inst        Module  `json:"-"`
	Name        string  `json:"name"`
	Config      *Config `json:"config,omitempty"`
	Description string  `json:"description"`
	IsStarted   bool    `json:"started"`
}

Instance is a struct that describes a module instance

func GetModuleInstance

func GetModuleInstance(name string) (*Instance, error)

GetModuleInstance gets the module instance with the provided name.

func InitializeModule

func InitializeModule(
	ctx apitypes.Context, modConfig *Config) (*Instance, error)

InitializeModule initializes a module.

type Module

type Module interface {

	// Start starts the module.
	Start() error

	// Stop signals the module to stop.
	Stop() error

	// Name is the name of the module.
	Name() string

	// Address is the network address at which the module is available.
	Address() string

	// Description is a free-form field ot add descriptive information about
	// the module instance.
	Description() string
}

Module is the interface to which types adhere in order to participate as daemon modules.

type Type

type Type struct {
	Name     string `json:"name"`
	InitFunc Init   `json:"-"`
}

Type is a struct that describes a module type

Directories

Path Synopsis
csi

Jump to

Keyboard shortcuts

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