Documentation ¶
Index ¶
- type Agent
- type AgentReply
- type Manager
- func (a *Manager) Choria() inter.Framework
- func (a *Manager) DenyAgent(agent string)
- func (a *Manager) Dispatch(ctx context.Context, wg *sync.WaitGroup, replies chan *AgentReply, ...)
- func (a *Manager) Get(name string) (Agent, bool)
- func (a *Manager) KnownAgents() []string
- func (a *Manager) Logger() *logrus.Entry
- func (a *Manager) RegisterAgent(ctx context.Context, name string, agent Agent, conn inter.AgentConnector) error
- func (a *Manager) ReplaceAgent(name string, agent Agent) error
- func (a *Manager) UnregisterAgent(name string, conn inter.AgentConnector) error
- type Metadata
- type ServerInfoSource
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 ¶
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 ¶
func New(requests chan inter.ConnectorMessage, fw inter.Framework, conn inter.ConnectorInfo, srv ServerInfoSource, log *logrus.Entry) *Manager
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) 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) KnownAgents ¶
KnownAgents retrieves a list of known agents
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
func (*Manager) ReplaceAgent ¶ added in v0.28.0
ReplaceAgent allows an agent manager to replace an agent that is already known, and subsscribed, with another instance to facilitate in-place upgrades
func (*Manager) UnregisterAgent ¶ added in v0.28.0
func (a *Manager) UnregisterAgent(name string, conn inter.AgentConnector) error
UnregisterAgent attempts to remove interest in messages for an agent
Each agent has a number of subscriptions (one per collective) so this can fail for some while working for others, in this case the agent is essentially in an unrecoverable state however the cases where unsubscribe will error are quite few in the nats client as its not being-connected dependant and we handle most errors correctly.
So this function will try to unsubscribe but if it fails, it will continue and finally unload the agent, any stale subscriptions then will be dropped by the handlers so its ok. We will treat unsbuscribe errors as non terminal, only logging errors.
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