agents

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	Metadata() *Metadata
	Name() string
	HandleMessage(context.Context, inter.Message, protocol.Request, inter.ConnectorInfo, chan *AgentReply)
	SetServerInfo(ServerInfoSource)
	ServerInfo() ServerInfoSource
	ShouldActivate() bool
}

Agent is a generic choria agent

type AgentReply

type AgentReply struct {
	Body    []byte
	Request protocol.Request
	Message inter.Message
	Error   error
}

AgentReply is a generic reply from an agent

type Manager

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

Manager manages agents, handles registration, dispatches requests etc

func New

New creates a new Agent Manager

func NewServices added in v0.23.0

func NewServices(requests chan inter.ConnectorMessage, fw inter.Framework, conn inter.ConnectorInfo, srv ServerInfoSource, log *logrus.Entry) *Manager

NewServices creates an agent manager restricted to service agents

func (*Manager) Choria

func (a *Manager) Choria() inter.Framework

Choria provides an instance of the choria framework

func (*Manager) DenyAgent

func (a *Manager) DenyAgent(agent string)

DenyAgent adds an agent to the list of agent names not allowed to start

func (*Manager) Dispatch

func (a *Manager) Dispatch(ctx context.Context, wg *sync.WaitGroup, replies chan *AgentReply, msg inter.Message, request protocol.Request)

Dispatch sends a request to a agent and wait for a reply

func (*Manager) Get

func (a *Manager) Get(name string) (Agent, bool)

Get retrieves an agent by name

func (*Manager) KnownAgents

func (a *Manager) KnownAgents() []string

KnownAgents retrieves a list of known agents

func (*Manager) Logger

func (a *Manager) Logger() *logrus.Entry

Logger is the logger the manager prefers new agents derive from

func (*Manager) RegisterAgent

func (a *Manager) RegisterAgent(ctx context.Context, name string, agent Agent, conn inter.AgentConnector) error

RegisterAgent connects a new agent to the server instance, subscribe to all its targets etc

type Metadata

type Metadata struct {
	License     string `json:"license"`
	Author      string `json:"author"`
	Timeout     int    `json:"timeout"`
	Name        string `json:"name"`
	Version     string `json:"version"`
	URL         string `json:"url"`
	Description string `json:"description"`
	Provider    string `json:"provider,omitempty"`
	Service     bool   `json:"service,omitempty"`
}

Metadata describes an agent at a high level and is required for any agent

type ServerInfoSource

type ServerInfoSource interface {
	AgentMetadata(string) (Metadata, bool)
	BuildInfo() *build.Info
	Classes() []string
	ConfigFile() string
	ConnectedServer() string
	DataFuncMap() (ddl.FuncMap, error)
	Facts() json.RawMessage
	Identity() string
	KnownAgents() []string
	LastProcessedMessage() time.Time
	MachineTransition(name string, version string, path string, id string, transition string) error
	MachinesStatus() ([]aagent.MachineState, error)
	NewEvent(t lifecycle.Type, opts ...lifecycle.Option) error
	PrepareForShutdown() error
	Provisioning() bool
	StartTime() time.Time
	Stats() statistics.ServerStats
	UpTime() int64
}

ServerInfoSource provides data about a running server instance

Jump to

Keyboard shortcuts

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