core

package
v0.0.0-...-7f17660 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2015 License: Apache-2.0 Imports: 0 Imported by: 5

Documentation

Overview

Core interfaces and data structures that are used throughout AgentController

Index

Constants

View Source
const (
	COMMAND_STATE_QUEUED  = "QUEUED"
	COMMAND_STATE_RUNNING = "RUNNING"
	COMMAND_STATE_ERROR   = "ERROR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentID

type AgentID struct {
	GID uint
	NID uint
}

type AgentInformationStorage

type AgentInformationStorage interface {

	// Sets the roles associated with an Agent
	SetRoles(id AgentID, roles []AgentRole)

	// Gets the roles associated with an Agent
	GetRoles(id AgentID) []AgentRole

	// Drops all the known information about an Agent
	DropAgent(id AgentID)

	// Checks if the specified agent has the specified role
	HasRole(id AgentID, role AgentRole) bool

	// Queries for all the available Agents
	ConnectedAgents() []AgentID

	// Queries for all the available agents that specify the given criteria:
	//	- If gid is not nil, only returns IDs of Agents with that GID
	//	- if roles is not nil, only returns IDs of Agents that have all of these roles
	FilteredConnectedAgents(gid *uint, roles []AgentRole) []AgentID

	IsConnected(id AgentID) bool
}

Information about all things Agents

type AgentRole

type AgentRole string

type Command

type Command struct {
	ID     string   `json:"id"`
	Gid    int      `json:"gid"`
	Nid    int      `json:"nid"`
	Cmd    string   `json:"cmd"`
	Roles  []string `json:"roles"`
	Fanout bool     `json:"fanout"`
	Data   string   `json:"data"`
	Args   struct {
		Name string `json:"name"`
	} `json:"args"`
}

type CommandLogger

type CommandLogger interface {

	// Log the reception  of a certain command
	LogCommand(command *Command) error
}

type CommandResult

type CommandResult struct {
	ID        string `json:"id"`
	Nid       int    `json:"nid"`
	Gid       int    `json:"gid"`
	State     string `json:"state"`
	Data      string `json:"data"`
	Level     int    `json:"level"`
	StartTime int64  `json:"starttime"`
}

type CommandStorage

type CommandStorage interface {

	// Queues a received command
	QueueReceivedCommand(agentID AgentID, command *Command) error

	// Returns a channel of commands for the specified agents
	// Always returns the same channel for the same AgentID
	// Whatever internal implementation errors that arise in the command-producing channels should be handled
	// discretely
	CommandsForAgent(agentID AgentID) <-chan Command

	// Report that this command was dequeued for delivery to that agent but delivery to said Agent
	// failed for one reason or another
	ReportUndeliveredCommand(agentID AgentID, command *Command) error

	// Store the result of a command
	SetCommandResult(result *CommandResult) error
}

Persisted storage for incoming commands

type Incoming

type Incoming interface {

	// Receives and returns a single command without blocking, returning nil if there weren't any
	ReceiveCommand() (*Command, error)

	// Checks if the error is about a badly formatted incoming command
	IsCommandFormatError(err error) bool
}

AgentController's command input interface to its clients

Jump to

Keyboard shortcuts

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