model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 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

func ConvertConnIDToString added in v0.0.15

func ConvertConnIDToString(id any) string

ConvertConnIDToString converts the connection ID to a string.

Types

type Agent

type Agent struct {
	InstanceUID uuid.UUID

	// Agent To Server message
	Capabilities        *agent.Capabilities
	Description         *agent.Description
	EffectiveConfig     *AgentEffectiveConfig
	PackageStatuses     *AgentPackageStatuses
	ComponentHealth     *AgentComponentHealth
	RemoteConfig        remoteconfig.RemoteConfig
	CustomCapabilities  *AgentCustomCapabilities
	AvailableComponents *AgentAvailableComponents

	// ReportFullState is a flag to indicate whether the agent should report full state.
	// If true, the agent should report all state information.
	// More details, see https://github.com/open-telemetry/opamp-spec/blob/main/specification.md#servertoagentflags
	ReportFullState bool
}

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) IsManaged added in v0.0.15

func (a *Agent) IsManaged() bool

IsManaged is a method to check if the agent is unmanaged. If an agent is unmanaged, it means that it should be reported to the server with all its state information.

func (*Agent) ReportAvailableComponents

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

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

func (*Agent) ReportCapabilities added in v0.0.15

func (a *Agent) ReportCapabilities(capabilities *agent.Capabilities) error

ReportCapabilities is a method to report the capabilities 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.

func (*Agent) ResetByServerToAgent added in v0.0.15

func (a *Agent) ResetByServerToAgent() error

ResetByServerToAgent is a method to reset all fields that used to generate ServerToAgent message. It is called after the ServerToAgent message is sent to the agent.

func (*Agent) SetReportFullState added in v0.0.15

func (a *Agent) SetReportFullState(reportFullState bool)

SetReportFullState is a method to set the report full state of the agent.

type AgentAvailableComponents

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

AgentAvailableComponents is a map of available components.

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 {
	// Key is the unique identifier for the connection.
	// It should be unique across all connections to use as a key in a map.
	// Normally, it is [types.Connection] by OpAMP.
	ID any

	// Type is the type of the connection.
	Type Type

	// UID is the unique identifier for the connection.
	// It is used to identify the connection in the database.
	UID uuid.UUID

	// InstanceUID is id of the agent.
	InstanceUID uuid.UUID

	// LastCommunicatedAt is the last time the connection was communicated with.
	LastCommunicatedAt time.Time
}

Connection represents a connection to an agent.

func NewConnection

func NewConnection(id any, typ Type) *Connection

NewConnection creates a new Connection instance with the given ID and type.

func (*Connection) IDString added in v0.0.15

func (conn *Connection) IDString() string

IDString returns a string value In some cases, a unique string id instead of any type.

func (*Connection) IsAlive

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

IsAlive returns true if the connection is alive.

func (*Connection) IsAnonymous added in v0.0.15

func (conn *Connection) IsAnonymous() bool

IsAnonymous returns true if the connection is anonymous.

func (*Connection) IsManaged added in v0.0.15

func (conn *Connection) IsManaged() bool

IsManaged returns true if the connection is managed.

type Host

type Host struct{}

Host is a value object that represents a host.

type Type added in v0.0.15

type Type int

Type represents the type of the connection.

const (
	// TypeUnknown is the unknown type.
	TypeUnknown Type = iota
	// TypeHTTP is the HTTP type.
	TypeHTTP
	// TypeWebSocket is the WebSocket type.
	TypeWebSocket
)

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