Documentation
¶
Overview ¶
Package model provides domain models for the opampcommander application.
Index ¶
- Constants
- Variables
- func ConvertConnIDToString(id any) string
- type Agent
- func (a *Agent) ApplyRemoteConfig(config any, contentType string, priority int32) error
- func (a *Agent) ConnectedServerID() (*Server, error)
- func (a *Agent) GetCondition(conditionType AgentConditionType) *AgentCondition
- func (a *Agent) HasInstanceUID() bool
- func (a *Agent) HasNewInstanceUID() bool
- func (a *Agent) HasPendingServerMessages() bool
- func (a *Agent) HasRemoteConfig() bool
- func (a *Agent) IsConditionTrue(conditionType AgentConditionType) bool
- func (a *Agent) IsConnected(_ context.Context) bool
- func (a *Agent) IsRemoteConfigSupported() bool
- func (a *Agent) IsSupportRestart() bool
- func (a *Agent) MarkConfigured(triggeredBy string)
- func (a *Agent) MarkConnected(triggeredBy string)
- func (a *Agent) MarkDisconnected(triggeredBy string)
- func (a *Agent) MarkHealthy(triggeredBy string)
- func (a *Agent) MarkUnhealthy(triggeredBy, reason string)
- func (a *Agent) NeedFullStateCommand() bool
- func (a *Agent) NewInstanceUID() []byte
- func (a *Agent) RecordLastReported(by *Server, lastReportedAt time.Time, sequenceNum uint64)
- func (a *Agent) ReportAvailableComponents(availableComponents *AgentAvailableComponents) error
- func (a *Agent) ReportCapabilities(capabilities *agent.Capabilities) error
- func (a *Agent) ReportComponentHealth(health *AgentComponentHealth) error
- func (a *Agent) ReportCustomCapabilities(capabilities *AgentCustomCapabilities) error
- func (a *Agent) ReportDescription(desc *agent.Description) error
- func (a *Agent) ReportEffectiveConfig(config *AgentEffectiveConfig) error
- func (a *Agent) ReportPackageStatuses(status *AgentPackageStatuses) error
- func (a *Agent) ReportRemoteConfigStatus(status *AgentRemoteConfigStatus) error
- func (a *Agent) SetCondition(conditionType AgentConditionType, status AgentConditionStatus, ...)
- func (a *Agent) SetRestartRequired(requiredAt time.Time) error
- func (a *Agent) ShouldBeRestarted() bool
- func (a *Agent) UpdateLastCommunicationInfo(now time.Time, connection *Connection)
- type AgentAvailableComponents
- type AgentCommand
- type AgentCommands
- func (ac *AgentCommands) Clear() []AgentCommand
- func (ac *AgentCommands) HasReportFullStateCommand() bool
- func (ac *AgentCommands) SendRemoteConfigUpdated(configHash vo.Hash, requestedAt time.Time, requestedBy string)
- func (ac *AgentCommands) SendReportFullState(reportFullState bool, requestedAt time.Time, requestedBy string)
- type AgentComponentHealth
- type AgentCondition
- type AgentConditionStatus
- type AgentConditionType
- type AgentConfig
- type AgentConfigFile
- type AgentConfigMap
- type AgentCustomCapabilities
- type AgentEffectiveConfig
- type AgentGroup
- type AgentGroupMetadata
- type AgentGroupSpec
- type AgentGroupStatus
- type AgentMetadata
- type AgentOption
- func WithAvailableComponents(availableComponents *AgentAvailableComponents) AgentOption
- func WithCapabilities(capabilities *agent.Capabilities) AgentOption
- func WithComponentHealth(componentHealth *AgentComponentHealth) AgentOption
- func WithCustomCapabilities(customCapabilities *AgentCustomCapabilities) AgentOption
- func WithDescription(description *agent.Description) AgentOption
- func WithEffectiveConfig(effectiveConfig *AgentEffectiveConfig) AgentOption
- func WithPackageStatuses(packageStatuses *AgentPackageStatuses) AgentOption
- type AgentPackageStatus
- type AgentPackageStatusEnum
- type AgentPackageStatuses
- type AgentRemoteConfigStatus
- type AgentRestartInfo
- type AgentSelector
- type AgentSpec
- type AgentStatus
- type Attributes
- type ComponentDetails
- type Condition
- type ConditionStatus
- type ConditionType
- type Connection
- type ConnectionType
- type Host
- type ListOptions
- type ListResponse
- type RemoteConfig
- type RemoteConfigStatus
- type Server
- func (s *Server) GetCondition(conditionType ServerConditionType) *ServerCondition
- func (s *Server) GetRegisteredAt() *time.Time
- func (s *Server) GetRegisteredBy() string
- func (s *Server) IsAlive(now time.Time, timeout time.Duration) bool
- func (s *Server) IsConditionTrue(conditionType ServerConditionType) bool
- func (s *Server) MarkAlive(reason string)
- func (s *Server) MarkNotAlive(reason string)
- func (s *Server) MarkRegistered(reason string)
- func (s *Server) SetCondition(conditionType ServerConditionType, status ServerConditionStatus, ...)
- type ServerCondition
- type ServerConditionStatus
- type ServerConditionType
Constants ¶
const ( AgentPackageStatusEnumInstalled = 0 AgentPackageStatusEnumInstallPending = 1 AgentPackageStatusEnumInstalling = 2 AgentPackageStatusEnumInstallFailed = 3 AgentPackageStatusEnumDownloading = 4 )
AgentPackageStatusEnum values The AgentPackageStatusEnum enum is defined in the opamp protocol.
const ( // OpAMPPollingInterval is a polling interval for OpAMP. // ref. https://github.com/minuk-dev/opampcommander/issues/8 OpAMPPollingInterval = 30 * time.Second )
Variables ¶
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
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
ApplyRemoteConfig is a method to apply the remote configuration to the agent.
func (*Agent) ConnectedServerID ¶ added in v0.1.22
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
HasInstanceUID checks if the agent has a valid instance UID.
func (*Agent) HasNewInstanceUID ¶ added in v0.1.24
HasNewInstanceUID checks if there is a new instance UID to inform the agent.
func (*Agent) HasPendingServerMessages ¶ added in v0.1.22
HasPendingServerMessages checks if there are any pending server messages for the agent.
func (*Agent) HasRemoteConfig ¶ added in v0.1.24
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
IsConnected checks if the agent is currently connected.
func (*Agent) IsRemoteConfigSupported ¶ added in v0.1.24
IsRemoteConfigSupported checks if the agent supports remote configuration.
func (*Agent) IsSupportRestart ¶ added in v0.1.24
IsSupportRestart checks if the agent supports restart command.
func (*Agent) MarkConfigured ¶ added in v0.1.24
MarkConfigured marks the agent as configured.
func (*Agent) MarkConnected ¶ added in v0.1.24
MarkConnected marks the agent as connected and updates the connection condition.
func (*Agent) MarkDisconnected ¶ added in v0.1.24
MarkDisconnected marks the agent as disconnected and updates the connection condition.
func (*Agent) MarkHealthy ¶ added in v0.1.24
MarkHealthy marks the agent as healthy.
func (*Agent) MarkUnhealthy ¶ added in v0.1.24
MarkUnhealthy marks the agent as unhealthy.
func (*Agent) NeedFullStateCommand ¶ added in v0.1.24
NeedFullStateCommand checks if the agent needs to send a ReportFullState command.
func (*Agent) NewInstanceUID ¶ added in v0.1.24
NewInstanceUID returns the new instance UID to inform the agent.
func (*Agent) RecordLastReported ¶ added in v0.1.22
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
SetRestartRequired sets the restart required information for the agent.
func (*Agent) ShouldBeRestarted ¶ added in v0.1.24
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
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 ListOptions ¶ added in v0.1.9
ListOptions is a struct that holds options for listing resources.
type ListResponse ¶ added in v0.1.9
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.
const ( RemoteConfigStatusUnset RemoteConfigStatus = RemoteConfigStatus( int32(protobufs.RemoteConfigStatuses_RemoteConfigStatuses_UNSET)) RemoteConfigStatusApplied RemoteConfigStatus = RemoteConfigStatus( int32(protobufs.RemoteConfigStatuses_RemoteConfigStatuses_APPLIED)) RemoteConfigStatusApplying RemoteConfigStatus = RemoteConfigStatus( int32(protobufs.RemoteConfigStatuses_RemoteConfigStatuses_APPLYING)) RemoteConfigStatusFailed RemoteConfigStatus = RemoteConfigStatus( int32(protobufs.RemoteConfigStatuses_RemoteConfigStatuses_FAILED)) )
RemoteConfigStatus constants To manage simply, we use opamp-go's protobufs' value.
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
GetRegisteredAt returns the timestamp when the server was registered.
func (*Server) GetRegisteredBy ¶ added in v0.1.24
GetRegisteredBy returns the identifier of the user or system that registered the server.
func (*Server) IsAlive ¶ added in v0.1.22
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) MarkNotAlive ¶ added in v0.1.24
MarkNotAlive marks the server as not alive.
func (*Server) MarkRegistered ¶ added in v0.1.24
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" )
Source Files
¶
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 |