model

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package model provides domain models for the opampcommander application.

Index

Constants

View Source
const (
	AgentPackageStatusEnumInstalled      = 0
	AgentPackageStatusEnumInstallPending = 1
	AgentPackageStatusEnumInstalling     = 2
	AgentPackageStatusEnumInstallFailed  = 3
	AgentPackageStatusEnumDownloading    = 4
)

AgentPackageStatusEnum values The AgentPackageStatusEnum enum is defined in the opamp protocol.

View Source
const (
	// OpAMPPollingInterval is a polling interval for OpAMP.
	// ref. https://github.com/minuk-dev/opampcommander/issues/8
	OpAMPPollingInterval = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	InstanceUID         uuid.UUID
	Capabilities        *AgentCapabilities
	Description         *agent.Description
	EffectiveConfig     *AgentEffectiveConfig
	PackageStatuses     *AgentPackageStatuses
	ComponentHealth     *AgentComponentHealth
	RemoteConfig        remoteconfig.RemoteConfig
	CustomCapabilities  *AgentCustomCapabilities
	AvailableComponents *AgentAvailableComponents
}

Agent is a domain model to control opamp agent by opampcommander.

func (*Agent) ApplyRemoteConfig added in v0.0.2

func (a *Agent) ApplyRemoteConfig(config any) error

ApplyRemoteConfig is a method to apply the remote configuration to the agent.

func (*Agent) ReportAvailableComponents

func (a *Agent) ReportAvailableComponents(availableComponents *AgentAvailableComponents) error

ReportAvailableComponents is a method to report the available components of the agent.

func (*Agent) ReportComponentHealth

func (a *Agent) ReportComponentHealth(health *AgentComponentHealth) error

ReportComponentHealth is a method to report the component health of the agent.

func (*Agent) ReportCustomCapabilities

func (a *Agent) ReportCustomCapabilities(capabilities *AgentCustomCapabilities) error

ReportCustomCapabilities is a method to report the custom capabilities of the agent.

func (*Agent) ReportDescription

func (a *Agent) ReportDescription(desc *agent.Description) error

ReportDescription is a method to report the description of the agent.

func (*Agent) ReportEffectiveConfig

func (a *Agent) ReportEffectiveConfig(config *AgentEffectiveConfig) error

ReportEffectiveConfig is a method to report the effective configuration of the agent.

func (*Agent) ReportPackageStatuses

func (a *Agent) ReportPackageStatuses(status *AgentPackageStatuses) error

ReportPackageStatuses is a method to report the package statuses of the agent.

func (*Agent) ReportRemoteConfigStatus

func (a *Agent) ReportRemoteConfigStatus(status *AgentRemoteConfigStatus) error

ReportRemoteConfigStatus is a method to report the remote configuration status of the agent.

type AgentAvailableComponents

type AgentAvailableComponents struct {
	Components map[string]ComponentDetails
	Hash       []byte
}

AgentAvailableComponents is a map of available components.

type AgentCapabilities

type AgentCapabilities uint64

AgentCapabilities is a bitmask of capabilities that the Agent supports. The AgentCapabilities enum is defined in the opamp protocol.

type AgentComponentHealth

type AgentComponentHealth struct {
	// Set to true if the Agent is up and healthy.
	Healthy bool

	// Timestamp since the Agent is up
	StartTime time.Time

	// Human-readable error message if the Agent is in erroneous state. SHOULD be set when healthy==false.
	LastError string

	// Component status represented as a string.
	// The status values are defined by agent-specific semantics and not at the protocol level.
	Status string

	// The time when the component status was observed.
	StatusTime time.Time

	// A map to store more granular, sub-component health.
	// It can nest as deeply as needed to describe the underlying system.
	ComponentHealthMap map[string]AgentComponentHealth
}

AgentComponentHealth is a domain model to control opamp agent component health.

type AgentConfigFile

type AgentConfigFile struct {
	// The body field contains the raw bytes of the configuration file.
	// The content, format and encoding of the raw bytes is Agent type-specific and is outside the concerns of OpAMP
	// protocol.
	Body []byte

	// content_type is an optional field. It is a MIME Content-Type that describes what's contained in the body field,
	// for example "text/yaml". The content_type reported in the Effective Configuration in the Agent's status report may
	// be used for example by the Server to visualize the reported configuration nicely in a UI.
	ContentType string
}

AgentConfigFile is a configuration file.

type AgentConfigMap

type AgentConfigMap struct {
	// The config_map field of the AgentConfigSet message is a map of configuration files, where keys are file names.
	ConfigMap map[string]AgentConfigFile
}

AgentConfigMap is a map of configuration files.

type AgentCustomCapabilities

type AgentCustomCapabilities struct {
	Capabilities []string
}

AgentCustomCapabilities is a list of custom capabilities that the Agent supports.

type AgentEffectiveConfig

type AgentEffectiveConfig struct {
	ConfigMap AgentConfigMap
}

AgentEffectiveConfig is the effective configuration of the agent.

type AgentPackageStatus

type AgentPackageStatus struct {
	Name                 string
	AgentHasVersion      string
	AgentHasHash         []byte
	ServerOfferedVersion string
	Status               AgentPackageStatusEnum
	ErrorMessage         string
}

AgentPackageStatus is the status of a package.

type AgentPackageStatusEnum

type AgentPackageStatusEnum int32

AgentPackageStatusEnum is an enum that represents the status of a package.

type AgentPackageStatuses

type AgentPackageStatuses struct {
	Packages                     map[string]AgentPackageStatus
	ServerProvidedAllPackgesHash []byte
	ErrorMessage                 string
}

AgentPackageStatuses is a map of package statuses.

type AgentRemoteConfigStatus

type AgentRemoteConfigStatus struct {
	LastRemoteConfigHash []byte
	Status               remoteconfig.Status
	ErrorMessage         string
}

AgentRemoteConfigStatus is the status of the remote configuration.

type Command

type Command struct {
	Kind CommandKind

	ID                uuid.UUID
	TargetInstanceUID uuid.UUID
	Data              map[string]any
}

Command represents a command to be sent to an agent.

func NewUpdateAgentConfigCommand

func NewUpdateAgentConfigCommand(targetInstanceUID uuid.UUID, remoteConfig any) *Command

NewUpdateAgentConfigCommand creates a new command to update the agent configuration.

type CommandKind

type CommandKind string

CommandKind represents the type of command to be sent to an agent.

const (
	// UpdateAgentConfigCommandKind is the command kind for updating agent configuration.
	UpdateAgentConfigCommandKind CommandKind = "UpdateAgentConfig"
)

type ComponentDetails

type ComponentDetails struct {
	Metadata        map[string]string
	SubComponentMap map[string]ComponentDetails
}

ComponentDetails is a details of a component.

type Connection

type Connection struct {
	ID uuid.UUID
	// contains filtered or unexported fields
}

Connection represents a connection to an agent.

func NewConnection

func NewConnection(id uuid.UUID) *Connection

NewConnection returns a new Connection instance.

func (*Connection) Close

func (conn *Connection) Close() error

Close closes the connection. Even if already closed, do nothing.

func (*Connection) IsAlive

func (conn *Connection) IsAlive(now time.Time) bool

IsAlive returns true if the connection is alive.

func (*Connection) LastCommunicatedAt

func (conn *Connection) LastCommunicatedAt() time.Time

LastCommunicatedAt returns the last communicated time.

func (*Connection) RefreshLastCommunicatedAt

func (conn *Connection) RefreshLastCommunicatedAt(at time.Time)

RefreshLastCommunicatedAt refreshes the last communicated time.

type Host

type Host struct{}

Host is a value object that represents a host.

Directories

Path Synopsis
Package agent provides domain models for the agent
Package agent provides domain models for the agent
Package remoteconfig provides the remote config for opampcommander.
Package remoteconfig provides the remote config for opampcommander.
Package vo provides value objects vo package does not have any dependencies on other packages except the standard library
Package vo provides value objects vo package does not have any dependencies on other packages except the standard library

Jump to

Keyboard shortcuts

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