Documentation
¶
Overview ¶
Package opamp provides the implementation of the OpAMP use case for managing connections and agents.
Index ¶
- Constants
- Variables
- type Service
- func (s *Service) Name() string
- func (s *Service) OnConnected(ctx context.Context, conn types.Connection)deprecated
- func (s *Service) OnConnectedWithType(ctx context.Context, conn types.Connection, isWebSocket bool)
- func (s *Service) OnConnectionClose(conn types.Connection)
- func (s *Service) OnMessage(ctx context.Context, conn types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent
- func (s *Service) OnMessageResponseError(conn types.Connection, message *protobufs.ServerToAgent, err error)
- func (s *Service) OnReadMessageError(conn types.Connection, messageType int, msgByte []byte, err error)
- func (s *Service) Run(ctx context.Context) error
Constants ¶
const ( // DefaultOnConnectionCloseTimeout is the default timeout for closing a connection. DefaultOnConnectionCloseTimeout = 5 * time.Second )
Variables ¶
var ( // ErrNotSupportedOperation is returned when the operation is not supported by the agent. ErrNotSupportedOperation = errors.New("operation not supported by the agent") )
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a struct that implements the OpAMPUsecase interface.
func New ¶
func New( agentUsecase agentport.AgentUsecase, connectionUsecase agentport.ConnectionUsecase, serverIdentityProvider agentport.ServerIdentityProvider, agentGroupUsecase agentport.AgentGroupUsecase, agentNotificationUsecase agentport.AgentNotificationUsecase, agentPackageUsecase agentport.AgentPackageUsecase, agentRemoteConfigUsecase agentport.AgentRemoteConfigUsecase, logger *slog.Logger, ) *Service
New creates a new instance of the OpAMP service.
func (*Service) OnConnected
deprecated
added in
v0.0.15
func (s *Service) OnConnected(ctx context.Context, conn types.Connection)
OnConnected implements port.OpAMPUsecase.
Deprecated: Use OnConnectedWithType instead for proper connection type detection.
func (*Service) OnConnectedWithType ¶ added in v0.1.26
OnConnectedWithType implements port.OpAMPUsecase. This is called for both WebSocket and HTTP connections. isWebSocket parameter indicates the connection type.
func (*Service) OnConnectionClose ¶ added in v0.0.15
func (s *Service) OnConnectionClose(conn types.Connection)
OnConnectionClose implements port.OpAMPUsecase.
func (*Service) OnMessage ¶ added in v0.0.15
func (s *Service) OnMessage( ctx context.Context, conn types.Connection, message *protobufs.AgentToServer, ) *protobufs.ServerToAgent
OnMessage implements port.OpAMPUsecase. [1] find agentmodel.Connection by types.Connection [1-1] if not found, unexpected case because all connections should be created when OnConnected is called. so, leave error log and skip connection processing. [2] find agentmodel.Agent by instanceUID in message [2-1] if not found, this is the first time the agent connects, so create a new agent with default values. [3] process the message and update agent state accordingly [4] save the updated agent [5] fetch ServerToAgent message to send back to the agent [6] return the ServerToAgent message.
func (*Service) OnMessageResponseError ¶ added in v0.1.22
func (s *Service) OnMessageResponseError(conn types.Connection, message *protobufs.ServerToAgent, err error)
OnMessageResponseError implements port.OpAMPUsecase.
func (*Service) OnReadMessageError ¶ added in v0.1.18
func (s *Service) OnReadMessageError( conn types.Connection, messageType int, msgByte []byte, err error, )
OnReadMessageError implements port.OpAMPUsecase.