opamp

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package opamp provides the implementation of the OpAMP use case for managing connections and agents.

Index

Constants

View Source
const (
	// DefaultOnConnectionCloseTimeout is the default timeout for closing a connection.
	DefaultOnConnectionCloseTimeout = 5 * time.Second
)

Variables

View Source
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) Name added in v0.0.16

func (s *Service) Name() string

Name returns the name of the 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

func (s *Service) OnConnectedWithType(ctx context.Context, conn types.Connection, isWebSocket bool)

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.

func (*Service) Run added in v0.0.15

func (s *Service) Run(ctx context.Context) error

Run starts a loop to handle asynchronous operations for the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL