Documentation
¶
Overview ¶
Package model provides domain models for the opampcommander application.
Index ¶
- Constants
- func ConvertConnIDToString(id any) string
- type Agent
- func (a *Agent) ApplyRemoteConfig(config any) error
- func (a *Agent) ConnectedServerID() (*Server, error)
- func (a *Agent) HasPendingServerMessages() bool
- func (a *Agent) IsConnected(_ context.Context) bool
- func (a *Agent) RecordLastReported(by *Server, at time.Time)
- 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) SetReportFullState(reportFullState bool, requestedAt time.Time, requestedBy string)
- func (a *Agent) UpdateLastCommunicationInfo(now time.Time)
- 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 AgentConfigFile
- type AgentConfigMap
- type AgentCustomCapabilities
- type AgentEffectiveConfig
- 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
- func WithRemoteConfigStatus(remoteConfigStatus *AgentRemoteConfigStatus) AgentOption
- type AgentPackageStatus
- type AgentPackageStatusEnum
- type AgentPackageStatuses
- type AgentRemoteConfigStatus
- type AgentSelector
- type AgentSpec
- type AgentStatus
- type Command
- type CommandKind
- type ComponentDetails
- type Connection
- type ConnectionType
- type Host
- type ListOptions
- type ListResponse
- type RemoteConfig
- func (r *RemoteConfig) ApplyRemoteConfig(configData RemoteConfigData) error
- func (r *RemoteConfig) GetCurrentConfig() RemoteConfigData
- func (r *RemoteConfig) GetStatus(key vo.Hash) RemoteConfigStatus
- func (r *RemoteConfig) IsManaged() bool
- func (r *RemoteConfig) SetLastErrorMessage(errorMessage string)
- func (r *RemoteConfig) SetStatus(key vo.Hash, status RemoteConfigStatus)
- type RemoteConfigData
- type RemoteConfigStatus
- type Server
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 ¶
This section is empty.
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
Commands AgentCommands
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) HasPendingServerMessages ¶ added in v0.1.22
HasPendingServerMessages checks if there are any pending server messages for the agent.
func (*Agent) IsConnected ¶ added in v0.1.22
IsConnected checks if the agent is currently connected.
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) SetReportFullState ¶ added in v0.0.15
SetReportFullState is a method to set the report full state of the agent.
func (*Agent) UpdateLastCommunicationInfo ¶ added in v0.1.22
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 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 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.
func WithRemoteConfigStatus ¶ added in v0.1.22
func WithRemoteConfigStatus(remoteConfigStatus *AgentRemoteConfigStatus) AgentOption
WithRemoteConfigStatus sets the agent remote config status.
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
}
AgentRemoteConfigStatus is the status of the remote configuration.
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 {
RemoteConfig RemoteConfig
}
AgentSpec is a domain model to control opamp agent spec. AgentSpec is a domain model to control opamp agent spec.
type AgentStatus ¶ added in v0.1.22
type AgentStatus struct {
EffectiveConfig AgentEffectiveConfig
PackageStatuses AgentPackageStatuses
ComponentHealth AgentComponentHealth
AvailableComponents AgentAvailableComponents
Connected bool
LastReportedAt time.Time
LastReportedTo *Server
}
AgentStatus is a domain model to control opamp agent status.
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.
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 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 (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 {
ConfigData RemoteConfigData
LastErrorMessage string
LastModifiedAt time.Time
}
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 RemoteConfigData) error
ApplyRemoteConfig applies remote config.
func (*RemoteConfig) GetCurrentConfig ¶ added in v0.1.22
func (r *RemoteConfig) GetCurrentConfig() RemoteConfigData
GetCurrentConfig returns the current config data.
func (*RemoteConfig) GetStatus ¶ added in v0.1.22
func (r *RemoteConfig) GetStatus(key vo.Hash) RemoteConfigStatus
GetStatus gets status with key.
func (*RemoteConfig) IsManaged ¶ added in v0.1.22
func (r *RemoteConfig) IsManaged() bool
IsManaged returns whether the agent is managed by the server. An agent is considered managed if it has remote config.
func (*RemoteConfig) SetLastErrorMessage ¶ added in v0.1.22
func (r *RemoteConfig) SetLastErrorMessage(errorMessage string)
SetLastErrorMessage sets last error message.
func (*RemoteConfig) SetStatus ¶ added in v0.1.22
func (r *RemoteConfig) SetStatus(key vo.Hash, status RemoteConfigStatus)
SetStatus sets status with key.
type RemoteConfigData ¶ added in v0.1.22
type RemoteConfigData struct {
Key vo.Hash
Status RemoteConfigStatus
Config []byte
LastUpdatedAt time.Time
}
RemoteConfigData is a struct to manage remote config data with status.
func NewRemoteConfigData ¶ added in v0.1.22
func NewRemoteConfigData(config any) (RemoteConfigData, error)
NewRemoteConfigData creates a new RemoteConfigData instance from 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
// CreatedAt is the time the server was first registered.
CreatedAt time.Time
}
Server represents a server that an agent communicates with. It contains the server's unique identifier and liveness information.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides domain models for the agent
|
Package agent provides domain models for the agent |
|
Package agentgroup defines the AgentGroup model and related types.
|
Package agentgroup defines the AgentGroup model and related types. |
|
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 |