agency

package
v0.0.0-...-a556200 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 19 Imported by: 0

Documentation

Overview

Package agency is used for running a single agency: management of agents located in same container / pod

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartAgency

func StartAgency(task func(*Agent) error) (err error)

StartAgency is the entrance function of agency

Types

type ACL

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

ACL provides functionality for agent messaging

func (*ACL) NewMessage

func (acl *ACL) NewMessage(receiver int, prot int, perf int,
	content string) (msg schemas.ACLMessage, err error)

NewMessage returns a new initiaized message

func (*ACL) RecvMessageWait

func (acl *ACL) RecvMessageWait() (msg schemas.ACLMessage, err error)

RecvMessageWait retrieves next message and blocks if no message is available

func (*ACL) RecvMessages

func (acl *ACL) RecvMessages() (num int, msgs []schemas.ACLMessage, err error)

RecvMessages retrieves all messages since last call of this function

func (*ACL) SendMessage

func (acl *ACL) SendMessage(msg schemas.ACLMessage) (err error)

SendMessage sends a message

type Agency

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

Agency contains information about agents located in agency

type Agent

type Agent struct {
	ACL    *ACL                // agent communication
	Logger *client.AgentLogger // logger object
	MQTT   *AgentMQTT          // mqtt object
	DF     *client.AgentDF
	// contains filtered or unexported fields
}

Agent holds information about an agent and implements functionality for agent execution

func (*Agent) GetAgentID

func (agent *Agent) GetAgentID() (ret int)

GetAgentID returns the agent ID

func (*Agent) GetAgentName

func (agent *Agent) GetAgentName() (ret string)

GetAgentName returns the agent name

func (*Agent) GetAgentType

func (agent *Agent) GetAgentType() (aType string, aSubtype string)

GetAgentType returns the agent type and subtype

func (*Agent) GetCustomData

func (agent *Agent) GetCustomData() (ret string)

GetCustomData returns custom data

func (*Agent) GetMASCustomData

func (agent *Agent) GetMASCustomData() (ret string)

GetMASVustom returns mas custom config

func (*Agent) GetMASID

func (agent *Agent) GetMASID() (ret int)

GetMASID returns mas id

func (*Agent) GetMASName

func (agent *Agent) GetMASName() (ret string)

GetMASName returns mas name

func (*Agent) NewCustomUpdateBehavior

func (agent *Agent) NewCustomUpdateBehavior(
	handle func(custom string) error) (behavior Behavior, err error)

NewCustomUpdateBehavior creates a new handler for custom config update actions

func (*Agent) NewMQTTTopicBehavior

func (agent *Agent) NewMQTTTopicBehavior(topic string,
	handle func(schemas.MQTTMessage) error) (behavior Behavior, err error)

NewMQTTTopicBehavior creates a new handler for messages of the specified topic

func (*Agent) NewMessageBehavior

func (agent *Agent) NewMessageBehavior(protocol int,
	handlePerformative map[int]func(schemas.ACLMessage) error,
	handleDefault func(schemas.ACLMessage) error) (behavior Behavior, err error)

NewMessageBehavior creates a new handler for messages of the specified protocol

func (*Agent) NewPeriodicBehavior

func (agent *Agent) NewPeriodicBehavior(period time.Duration,
	handle func() error) (behavior Behavior, err error)

NewPeriodicBehavior creates a new handler for periodic actions

func (*Agent) Terminate

func (agent *Agent) Terminate()

Terminate terminates the agent

type AgentMQTT

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

AgentMQTT provides functions to subscribe and publish via mqtt

func (*AgentMQTT) NewMessage

func (mq *AgentMQTT) NewMessage(topic string, content []byte) (msg schemas.MQTTMessage, err error)

NewMessage returns a new initiaized message

func (*AgentMQTT) RecvMessageWait

func (mq *AgentMQTT) RecvMessageWait() (msg schemas.MQTTMessage, err error)

RecvMessageWait retrieves next message and blocks if no message is available

func (*AgentMQTT) RecvMessages

func (mq *AgentMQTT) RecvMessages() (num int, msgs []schemas.MQTTMessage, err error)

RecvMessages retrieves all messages since last call of this function

func (*AgentMQTT) SendMessage

func (mq *AgentMQTT) SendMessage(msg schemas.MQTTMessage, qos int) (err error)

SendMessage sends a message

func (*AgentMQTT) Subscribe

func (mq *AgentMQTT) Subscribe(topic string, qos int) (err error)

Subscribe subscribes to a topic

func (*AgentMQTT) Unsubscribe

func (mq *AgentMQTT) Unsubscribe(topic string) (err error)

Unsubscribe unsubscribes a topic

type Behavior

type Behavior interface {
	Start()
	Stop()
}

Behavior defines execution of a certain behavior

Jump to

Keyboard shortcuts

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