model

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 14 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

View Source
var (
	// ErrUnsupportedRemoteConfigContentType is returned when the remote config content type is not supported.
	ErrUnsupportedRemoteConfigContentType = errors.New("unsupported remote config content type")
	// ErrUnsupportedAgentOperation is returned when the agent does not support the requested operation.
	ErrUnsupportedAgentOperation = errors.New("unsupported agent operation")
)

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 {
	Metadata AgentMetadata
	Spec     AgentSpec
	Status   AgentStatus
}

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

func NewAgent added in v0.1.22

func NewAgent(instanceUID uuid.UUID, opts ...AgentOption) *Agent

NewAgent creates a new agent with the given instance UID. It initializes all fields with default values. You can optionally pass AgentOption functions to customize the agent.

func (*Agent) ApplyRemoteConfig added in v0.0.2

func (a *Agent) ApplyRemoteConfig(config any, contentType string, priority int32) error

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

func (*Agent) ConnectedServerID added in v0.1.22

func (a *Agent) ConnectedServerID() (*Server, error)

ConnectedServerID returns the server the agent is currently connected to.

func (*Agent) GetCondition added in v0.1.24

func (a *Agent) GetCondition(conditionType AgentConditionType) *AgentCondition

GetCondition returns the condition of the specified type.

func (*Agent) HasInstanceUID added in v0.1.24

func (a *Agent) HasInstanceUID() bool

HasInstanceUID checks if the agent has a valid instance UID.

func (*Agent) HasNewInstanceUID added in v0.1.24

func (a *Agent) HasNewInstanceUID() bool

HasNewInstanceUID checks if there is a new instance UID to inform the agent.

func (*Agent) HasPendingServerMessages added in v0.1.22

func (a *Agent) HasPendingServerMessages() bool

HasPendingServerMessages checks if there are any pending server messages for the agent.

func (*Agent) HasRemoteConfig added in v0.1.24

func (a *Agent) HasRemoteConfig() bool

HasRemoteConfig checks if the agent has remote configuration to apply.

func (*Agent) IsConditionTrue added in v0.1.24

func (a *Agent) IsConditionTrue(conditionType AgentConditionType) bool

IsConditionTrue checks if the specified condition type is true.

func (*Agent) IsConnected added in v0.1.22

func (a *Agent) IsConnected(_ context.Context) bool

IsConnected checks if the agent is currently connected.

func (*Agent) IsRemoteConfigSupported added in v0.1.24

func (a *Agent) IsRemoteConfigSupported() bool

IsRemoteConfigSupported checks if the agent supports remote configuration.

func (*Agent) IsSupportRestart added in v0.1.24

func (a *Agent) IsSupportRestart() bool

IsSupportRestart checks if the agent supports restart command.

func (*Agent) MarkConfigured added in v0.1.24

func (a *Agent) MarkConfigured(triggeredBy string)

MarkConfigured marks the agent as configured.

func (*Agent) MarkConnected added in v0.1.24

func (a *Agent) MarkConnected(triggeredBy string)

MarkConnected marks the agent as connected and updates the connection condition.

func (*Agent) MarkDisconnected added in v0.1.24

func (a *Agent) MarkDisconnected(triggeredBy string)

MarkDisconnected marks the agent as disconnected and updates the connection condition.

func (*Agent) MarkHealthy added in v0.1.24

func (a *Agent) MarkHealthy(triggeredBy string)

MarkHealthy marks the agent as healthy.

func (*Agent) MarkUnhealthy added in v0.1.24

func (a *Agent) MarkUnhealthy(triggeredBy, reason string)

MarkUnhealthy marks the agent as unhealthy.

func (*Agent) NeedFullStateCommand added in v0.1.24

func (a *Agent) NeedFullStateCommand() bool

NeedFullStateCommand checks if the agent needs to send a ReportFullState command.

func (*Agent) NewInstanceUID added in v0.1.24

func (a *Agent) NewInstanceUID() []byte

NewInstanceUID returns the new instance UID to inform the agent.

func (*Agent) RecordLastReported added in v0.1.22

func (a *Agent) RecordLastReported(by *Server, lastReportedAt time.Time, sequenceNum uint64)

RecordLastReported updates the last communicated time and server of 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) 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) SetCondition added in v0.1.24

func (a *Agent) SetCondition(
	conditionType AgentConditionType,
	status AgentConditionStatus,
	triggeredBy, message string,
)

SetCondition sets or updates a condition in the agent's status.

func (*Agent) SetRestartRequired added in v0.1.24

func (a *Agent) SetRestartRequired(requiredAt time.Time) error

SetRestartRequired sets the restart required information for the agent.

func (*Agent) ShouldBeRestarted added in v0.1.24

func (a *Agent) ShouldBeRestarted() bool

ShouldBeRestarted checks if the agent should be restarted to apply a command that requires a restart.

func (*Agent) UpdateLastCommunicationInfo added in v0.1.22

func (a *Agent) UpdateLastCommunicationInfo(now time.Time, connection *Connection)

UpdateLastCommunicationInfo updates the last communication info of the agent.

type AgentAvailableComponents

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

AgentAvailableComponents is a map of available components.

type AgentCommand added in v0.1.22

type AgentCommand struct {
	// CommandID is a unique identifier for the command.
	CommandID uuid.UUID
	// 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
	// RemoteConfigUpdated is a flag to indicate that remote config has been updated.
	RemoteConfigUpdated bool
	// RemoteConfigUpdatedHash is the hash of the updated remote config.
	RemoteConfigUpdatedHash vo.Hash
	// CreatedAt is the time the command was created.
	CreatedAt time.Time
	// CreatedBy is the user who created the command.
	CreatedBy string
}

AgentCommand is a domain model to control opamp agent commands.

type AgentCommands added in v0.1.22

type AgentCommands struct {
	Commands []AgentCommand
}

AgentCommands is a list of commands to be sent to the agent.

func (*AgentCommands) Clear added in v0.1.22

func (ac *AgentCommands) Clear() []AgentCommand

Clear removes all commands and returns them.

func (*AgentCommands) HasReportFullStateCommand added in v0.1.22

func (ac *AgentCommands) HasReportFullStateCommand() bool

HasReportFullStateCommand checks if there's any ReportFullState command.

func (*AgentCommands) SendRemoteConfigUpdated added in v0.1.22

func (ac *AgentCommands) SendRemoteConfigUpdated(configHash vo.Hash, requestedAt time.Time, requestedBy string)

SendRemoteConfigUpdated adds a RemoteConfigUpdated command to the commands list.

func (*AgentCommands) SendReportFullState added in v0.1.22

func (ac *AgentCommands) SendReportFullState(reportFullState bool, requestedAt time.Time, requestedBy string)

SendReportFullState adds a ReportFullState command to the commands list.

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 AgentCondition added in v0.1.24

type AgentCondition struct {
	// Type is the type of the condition.
	Type AgentConditionType
	// LastTransitionTime is the last time the condition transitioned.
	LastTransitionTime time.Time
	// Status is the status of the condition.
	Status AgentConditionStatus
	// Reason is the identifier of the user or system that triggered the condition.
	Reason string
	// Message is a human readable message indicating details about the condition.
	Message string
}

AgentCondition represents a condition of an agent.

type AgentConditionStatus added in v0.1.24

type AgentConditionStatus string

AgentConditionStatus represents the status of an agent condition.

const (
	// AgentConditionStatusTrue represents a true condition status.
	AgentConditionStatusTrue AgentConditionStatus = "True"
	// AgentConditionStatusFalse represents a false condition status.
	AgentConditionStatusFalse AgentConditionStatus = "False"
	// AgentConditionStatusUnknown represents an unknown condition status.
	AgentConditionStatusUnknown AgentConditionStatus = "Unknown"
)

type AgentConditionType added in v0.1.24

type AgentConditionType string

AgentConditionType represents the type of an agent condition.

const (
	// AgentConditionTypeConnected represents the condition when the agent is connected.
	AgentConditionTypeConnected AgentConditionType = "Connected"
	// AgentConditionTypeHealthy represents the condition when the agent is healthy.
	AgentConditionTypeHealthy AgentConditionType = "Healthy"
	// AgentConditionTypeConfigured represents the condition when the agent has been configured.
	AgentConditionTypeConfigured AgentConditionType = "Configured"
	// AgentConditionTypeRegistered represents the condition when the agent has been registered.
	AgentConditionTypeRegistered AgentConditionType = "Registered"
)

type AgentConfig added in v0.1.24

type AgentConfig struct {
	// Value is the configuration content in string format.
	// This can be used directly or as a reference to a configuration.
	Value []byte

	// ContentType is the MIME type of the configuration content.
	ContentType string
}

AgentConfig represents the remote configuration for agents in the group.

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 AgentGroup added in v0.1.24

type AgentGroup struct {
	Metadata AgentGroupMetadata
	Spec     AgentGroupSpec
	Status   AgentGroupStatus
}

AgentGroup represents a group of agents with their associated metadata.

func NewAgentGroup added in v0.1.24

func NewAgentGroup(
	name string,
	attributes Attributes,
	createdAt time.Time,
	createdBy string,
) *AgentGroup

NewAgentGroup creates a new instance of AgentGroup with the provided name, attributes, createdAt timestamp, and createdBy identifier.

func (*AgentGroup) GetCreatedAt added in v0.1.24

func (ag *AgentGroup) GetCreatedAt() *time.Time

GetCreatedAt returns the timestamp when the agent group was created.

func (*AgentGroup) GetCreatedBy added in v0.1.24

func (ag *AgentGroup) GetCreatedBy() string

GetCreatedBy returns the identifier of the user or system that created the agent group.

func (*AgentGroup) GetDeletedAt added in v0.1.24

func (ag *AgentGroup) GetDeletedAt() *time.Time

GetDeletedAt returns the timestamp when the agent group was deleted.

func (*AgentGroup) GetDeletedBy added in v0.1.24

func (ag *AgentGroup) GetDeletedBy() *string

GetDeletedBy returns the identifier of the user or system that deleted the agent group.

func (*AgentGroup) IsDeleted added in v0.1.24

func (ag *AgentGroup) IsDeleted() bool

IsDeleted returns true if the agent group is marked as deleted.

func (*AgentGroup) MarkDeleted added in v0.1.24

func (ag *AgentGroup) MarkDeleted(deletedAt time.Time, deletedBy string)

MarkDeleted marks the agent group as deleted by adding a deleted condition.

type AgentGroupMetadata added in v0.1.24

type AgentGroupMetadata struct {
	// Name is the name of the agent group.
	Name string
	// Priority is the priority of the agent group.
	// When multiple agent groups match an agent, the one with the highest priority is applied.
	Priority int32
	// Attributes is a map of attributes associated with the agent group.
	Attributes Attributes
	// Selector is a set of criteria used to select agents for the group.
	Selector AgentSelector
}

AgentGroupMetadata represents metadata information for an agent group.

type AgentGroupSpec added in v0.1.24

type AgentGroupSpec struct {
	// AgentConfig is the remote configuration to be applied to agents in this group.
	AgentConfig *AgentConfig
}

AgentGroupSpec represents the specification of an agent group.

type AgentGroupStatus added in v0.1.24

type AgentGroupStatus struct {
	// NumAgents is the total number of agents in the agent group.
	// NumAgents = NumConnectedAgents + NumNotConnectedAgents
	NumAgents int

	// NumConnectedAgents is the number of connected agents in the agent group.
	// NumConnectedAgents = NumHealthyAgents + NumUnhealthyAgents
	NumConnectedAgents int

	// NumHealthyAgents is the number of healthy agents in the agent group.
	NumHealthyAgents int

	// NumUnhealthyAgents is the number of unhealthy agents in the agent group.
	NumUnhealthyAgents int

	// NumNotConnectedAgents is the number of not connected agents in the agent group.
	NumNotConnectedAgents int

	// Conditions is a list of conditions that apply to the agent group.
	Conditions []Condition
}

AgentGroupStatus represents the status of an agent group.

type AgentMetadata added in v0.1.22

type AgentMetadata struct {
	// InstanceUID is a unique identifier for the agent instance.
	// It is generated by the agent and should not change between restarts of the agent.
	InstanceUID uuid.UUID

	// Description is a agent description defined in the opamp protocol.
	// It is set by the agent and should not change between restarts of the agent.
	// It can be changed by the agent at any time.
	Description agent.Description

	// Capabilities is a agent capabilities defined in the opamp protocol.
	Capabilities agent.Capabilities

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

AgentMetadata is a domain model to control opamp agent metadata.

func (*AgentMetadata) IsComplete added in v0.1.22

func (am *AgentMetadata) IsComplete() bool

IsComplete checks if all required metadata fields are populated. Returns true if the agent has reported its description and capabilities.

type AgentOption added in v0.1.22

type AgentOption func(*Agent)

AgentOption is a function that configures an Agent.

func WithAvailableComponents added in v0.1.22

func WithAvailableComponents(availableComponents *AgentAvailableComponents) AgentOption

WithAvailableComponents sets the agent available components.

func WithCapabilities added in v0.1.22

func WithCapabilities(capabilities *agent.Capabilities) AgentOption

WithCapabilities sets the agent capabilities.

func WithComponentHealth added in v0.1.22

func WithComponentHealth(componentHealth *AgentComponentHealth) AgentOption

WithComponentHealth sets the agent component health.

func WithCustomCapabilities added in v0.1.22

func WithCustomCapabilities(customCapabilities *AgentCustomCapabilities) AgentOption

WithCustomCapabilities sets the agent custom capabilities.

func WithDescription added in v0.1.22

func WithDescription(description *agent.Description) AgentOption

WithDescription sets the agent description.

func WithEffectiveConfig added in v0.1.22

func WithEffectiveConfig(effectiveConfig *AgentEffectiveConfig) AgentOption

WithEffectiveConfig sets the agent effective config.

func WithPackageStatuses added in v0.1.22

func WithPackageStatuses(packageStatuses *AgentPackageStatuses) AgentOption

WithPackageStatuses sets the agent package statuses.

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               RemoteConfigStatus
	ErrorMessage         string
	LastUpdatedAt        time.Time
}

AgentRemoteConfigStatus is the status of the remote configuration.

type AgentRestartInfo added in v0.1.24

type AgentRestartInfo struct {
	// RequiredRestartedAt is the time when the agent is required to be
	// restarted to apply a command that requires a restart.
	RequiredRestartedAt time.Time
}

AgentRestartInfo is a domain model to control opamp agent restart information.

func (*AgentRestartInfo) ShouldBeRestarted added in v0.1.24

func (a *AgentRestartInfo) ShouldBeRestarted(agentStartTime time.Time) bool

ShouldBeRestarted checks if the agent should be restarted to apply a command that requires a restart.

type AgentSelector added in v0.1.22

type AgentSelector struct {
	// IdentifyingAttributes is a map of identifying attributes used to select agents.
	IdentifyingAttributes map[string]string
	// NonIdentifyingAttributes is a map of non-identifying attributes used to select agents.
	NonIdentifyingAttributes map[string]string
}

AgentSelector defines the criteria for selecting agent.

type AgentSpec added in v0.1.22

type AgentSpec struct {
	// NewInstanceUID is a new instance UID to inform the agent of its new identity.
	NewInstanceUID uuid.UUID

	// RemoteConfig is the remote configuration for the agent.
	RemoteConfig RemoteConfig

	// RestartInfo contains information about agent restart.
	RestartInfo AgentRestartInfo
}

AgentSpec is a domain model to control opamp agent spec.

type AgentStatus added in v0.1.22

type AgentStatus struct {
	RemoteConfigStatus  AgentRemoteConfigStatus
	EffectiveConfig     AgentEffectiveConfig
	PackageStatuses     AgentPackageStatuses
	ComponentHealth     AgentComponentHealth
	AvailableComponents AgentAvailableComponents

	// Conditions is a list of conditions that apply to the agent.
	Conditions []AgentCondition

	Connected      bool
	ConnectionType ConnectionType

	SequenceNum    uint64
	LastReportedAt time.Time
	LastReportedTo *Server
}

AgentStatus is a domain model to control opamp agent status.

type Attributes added in v0.1.24

type Attributes map[string]string

Attributes represents a map of attributes for the agent group.

func OfAttributes added in v0.1.24

func OfAttributes(attributes map[string]string) Attributes

OfAttributes creates an Attributes instance from a map of attributes.

type ComponentDetails

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

ComponentDetails is a details of a component.

type Condition added in v0.1.24

type Condition struct {
	// Type is the type of the condition.
	Type ConditionType
	// LastTransitionTime is the last time the condition transitioned.
	LastTransitionTime time.Time
	// Status is the status of the condition.
	Status ConditionStatus
	// Reason is the identifier of the user or system that triggered the condition.
	Reason string
	// Message is a human readable message indicating details about the condition.
	Message string
}

Condition represents a condition of an agent group.

type ConditionStatus added in v0.1.24

type ConditionStatus string

ConditionStatus represents the status of a condition.

const (
	// ConditionStatusTrue represents a true condition status.
	ConditionStatusTrue ConditionStatus = "True"
	// ConditionStatusFalse represents a false condition status.
	ConditionStatusFalse ConditionStatus = "False"
)

type ConditionType added in v0.1.24

type ConditionType string

ConditionType represents the type of a condition.

const (
	// ConditionTypeCreated represents the condition when the agent group was created.
	ConditionTypeCreated ConditionType = "Created"
	// ConditionTypeDeleted represents the condition when the agent group was deleted.
	ConditionTypeDeleted ConditionType = "Deleted"
)

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 ConnectionType

	// 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. This is a pure domain model containing only metadata about the connection. The actual WebSocket connection object is managed separately by the WebSocketRegistry.

func NewConnection

func NewConnection(id any, typ ConnectionType) *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.

func (*Connection) SetInstanceUID added in v0.1.22

func (conn *Connection) SetInstanceUID(instanceUID uuid.UUID)

SetInstanceUID sets the instance UID of the connection.

type ConnectionType added in v0.1.22

type ConnectionType int

ConnectionType represents the type of the connection.

const (
	// ConnectionTypeUnknown is the unknown type.
	ConnectionTypeUnknown ConnectionType = iota
	// ConnectionTypeHTTP is the HTTP type.
	ConnectionTypeHTTP
	// ConnectionTypeWebSocket is the WebSocket type.
	ConnectionTypeWebSocket
)

func ConnectionTypeFromString added in v0.1.24

func ConnectionTypeFromString(s string) ConnectionType

ConnectionTypeFromString converts a string to a ConnectionType.

func (ConnectionType) String added in v0.1.22

func (ct ConnectionType) String() string

String returns the string representation of the ConnectionType.

type Host

type Host struct{}

Host is a value object that represents a host.

type ListOptions added in v0.1.9

type ListOptions struct {
	Limit    int64
	Continue string
}

ListOptions is a struct that holds options for listing resources.

type ListResponse added in v0.1.9

type ListResponse[T any] struct {
	RemainingItemCount int64
	Continue           string
	Items              []T
}

ListResponse is a generic struct that represents a paginated response for listing resources.

type RemoteConfig added in v0.1.22

type RemoteConfig struct {
	Hash          vo.Hash
	Config        []byte
	ContentType   string
	LastUpdatedAt time.Time

	// ConfiguredBy is the identifier of the agentgroup or user who configured the remote config.
	ConfiguredBy string
	// Priority is the priority of the remote config. Higher priority configs override lower priority ones.
	Priority int32
}

RemoteConfig is a struct to manage remote config.

func NewRemoteConfig added in v0.1.22

func NewRemoteConfig() RemoteConfig

NewRemoteConfig creates a new RemoteConfig instance.

func (*RemoteConfig) ApplyRemoteConfig added in v0.1.22

func (r *RemoteConfig) ApplyRemoteConfig(configData []byte, contentType string) error

ApplyRemoteConfig applies remote config.

type RemoteConfigStatus added in v0.1.22

type RemoteConfigStatus int32

RemoteConfigStatus is generated from agentToServer of OpAMP.

func RemoteConfigStatusFromOpAMP added in v0.1.22

func RemoteConfigStatusFromOpAMP(status protobufs.RemoteConfigStatuses) RemoteConfigStatus

RemoteConfigStatusFromOpAMP converts OpAMP status to domain model.

func (RemoteConfigStatus) String added in v0.1.22

func (s RemoteConfigStatus) String() string

String returns the string representation of the status.

type Server added in v0.1.22

type Server struct {
	// ID is the unique identifier for the server.
	ID string
	// LastHeartbeatAt is the last time the server sent a heartbeat.
	LastHeartbeatAt time.Time
	// Conditions is a list of conditions that apply to the server.
	Conditions []ServerCondition
}

Server represents a server that an agent communicates with. It contains the server's unique identifier and liveness information.

func (*Server) GetCondition added in v0.1.24

func (s *Server) GetCondition(conditionType ServerConditionType) *ServerCondition

GetCondition returns the condition of the specified type.

func (*Server) GetRegisteredAt added in v0.1.24

func (s *Server) GetRegisteredAt() *time.Time

GetRegisteredAt returns the timestamp when the server was registered.

func (*Server) GetRegisteredBy added in v0.1.24

func (s *Server) GetRegisteredBy() string

GetRegisteredBy returns the identifier of the user or system that registered the server.

func (*Server) IsAlive added in v0.1.22

func (s *Server) IsAlive(now time.Time, timeout time.Duration) bool

IsAlive returns true if the server is alive based on the heartbeat timeout. A server is considered alive if its last heartbeat was within the timeout period.

func (*Server) IsConditionTrue added in v0.1.24

func (s *Server) IsConditionTrue(conditionType ServerConditionType) bool

IsConditionTrue checks if the specified condition type is true.

func (*Server) MarkAlive added in v0.1.24

func (s *Server) MarkAlive(reason string)

MarkAlive marks the server as alive.

func (*Server) MarkNotAlive added in v0.1.24

func (s *Server) MarkNotAlive(reason string)

MarkNotAlive marks the server as not alive.

func (*Server) MarkRegistered added in v0.1.24

func (s *Server) MarkRegistered(reason string)

MarkRegistered marks the server as registered.

func (*Server) SetCondition added in v0.1.24

func (s *Server) SetCondition(conditionType ServerConditionType, status ServerConditionStatus, reason, message string)

SetCondition sets or updates a condition in the server's status.

type ServerCondition added in v0.1.24

type ServerCondition struct {
	// Type is the type of the condition.
	Type ServerConditionType
	// LastTransitionTime is the last time the condition transitioned.
	LastTransitionTime time.Time
	// Status is the status of the condition.
	Status ServerConditionStatus
	// Reason is the identifier of the user or system that triggered the condition.
	Reason string
	// Message is a human readable message indicating details about the condition.
	Message string
}

ServerCondition represents a condition of a server.

type ServerConditionStatus added in v0.1.24

type ServerConditionStatus string

ServerConditionStatus represents the status of a server condition.

const (
	// ServerConditionStatusTrue represents a true condition status.
	ServerConditionStatusTrue ServerConditionStatus = "True"
	// ServerConditionStatusFalse represents a false condition status.
	ServerConditionStatusFalse ServerConditionStatus = "False"
	// ServerConditionStatusUnknown represents an unknown condition status.
	ServerConditionStatusUnknown ServerConditionStatus = "Unknown"
)

type ServerConditionType added in v0.1.24

type ServerConditionType string

ServerConditionType represents the type of a server condition.

const (
	// ServerConditionTypeRegistered represents the condition when the server was registered.
	ServerConditionTypeRegistered ServerConditionType = "Registered"
	// ServerConditionTypeAlive represents the condition when the server is alive.
	ServerConditionTypeAlive ServerConditionType = "Alive"
)

Directories

Path Synopsis
Package agent provides domain models for the agent
Package agent provides domain models for the agent
Package serverevent defines server-to-server event models.
Package serverevent defines server-to-server event models.
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