memory

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAgentExists   = errors.New("the agent already exists in the repository")
	ErrAgentNotFound = errors.New("the agent was not found in the repository")
)

Functions

This section is empty.

Types

type Repository

type Repository struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Repository structure implements an in-memory database that holds a map of agent's the server communicates with

func NewRepository

func NewRepository() *Repository

NewRepository creates and returns a Repository structure that contains an in-memory map of agents

func (*Repository) Add

func (r *Repository) Add(agent agents.Agent) error

Add locks the in-memory database and adds Agent structures to the map

func (*Repository) AddLinkedAgent

func (r *Repository) AddLinkedAgent(id uuid.UUID, link uuid.UUID) error

AddLinkedAgent updates the Agent's linkedAgents list the contains all child agents for which it is the parent

func (*Repository) Exists

func (r *Repository) Exists(id uuid.UUID) bool

Exists check's to see if the Agent is in the repository

func (*Repository) Get

func (r *Repository) Get(id uuid.UUID) (agents.Agent, error)

Get returns a COPY of the Agent entity. The caller should not try to modify the copy as it won't be updated in the repository

func (*Repository) GetAll

func (r *Repository) GetAll() (agents []agents.Agent)

GetAll returns a list of all Agents in the repository

func (*Repository) Log

func (r *Repository) Log(id uuid.UUID, message string) error

Log writes the provided message to the Agent's log file

func (*Repository) Remove

func (r *Repository) Remove(id uuid.UUID) (err error)

Remove deletes the agent from the repository

func (*Repository) RemoveLinkedAgent

func (r *Repository) RemoveLinkedAgent(id uuid.UUID, link uuid.UUID) error

RemoveLinkedAgent removed the provided link the Agent's linkedAgents list the contains all child agents for which it is the parent

func (*Repository) SetSecret

func (r *Repository) SetSecret(id uuid.UUID, secret []byte) error

SetSecret updates the agent's secret key, typically derived once authentication has completed and per-agent key has been established.

func (*Repository) Update

func (r *Repository) Update(agent agents.Agent) error

Update replaces the Agent in the repository with the one provided in the function call

func (*Repository) UpdateAlive

func (r *Repository) UpdateAlive(id uuid.UUID, alive bool) error

UpdateAlive updates the Agent's alive field to indicate if it is actively in use or not

func (*Repository) UpdateAuthenticated

func (r *Repository) UpdateAuthenticated(id uuid.UUID, authenticated bool) error

UpdateAuthenticated updates that Agent's authenticated field, typically once authentication has completed

func (*Repository) UpdateBuild

func (r *Repository) UpdateBuild(id uuid.UUID, build agents.Build) error

UpdateBuild updates the Agent's build field with the provided Build entity structure

func (*Repository) UpdateComms

func (r *Repository) UpdateComms(id uuid.UUID, comms agents.Comms) error

UpdateComms updates the Agent's comms field with the provided Comms entity structure

func (*Repository) UpdateHost

func (r *Repository) UpdateHost(id uuid.UUID, host agents.Host) error

UpdateHost updates the Agent's host field with the provided Host entity structure

func (*Repository) UpdateInitial

func (r *Repository) UpdateInitial(id uuid.UUID, t time.Time) error

UpdateInitial updates the Agent's initial field with the provided timestamp

func (*Repository) UpdateListener

func (r *Repository) UpdateListener(id, listener uuid.UUID) error

UpdateListener updates the ID of the listener the Agent is associated with

func (*Repository) UpdateNote

func (r *Repository) UpdateNote(id uuid.UUID, note string) error

UpdateNote updates the Agent's note field with the provided string

func (*Repository) UpdateProcess

func (r *Repository) UpdateProcess(id uuid.UUID, process agents.Process) error

UpdateProcess updates the Agent's process field with the provided Process entity structure

func (*Repository) UpdateStatusCheckin

func (r *Repository) UpdateStatusCheckin(id uuid.UUID, t time.Time) error

UpdateStatusCheckin updates the Agent's last checkin field with the provided timestamp

Jump to

Keyboard shortcuts

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