service

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package service provides the service layer for the opampcommander application.

Index

Constants

This section is empty.

Variables

View Source
var ErrNilArgument = errors.New("argument is nil")

ErrNilArgument is an error that indicates that the argument passed to a function is nil.

View Source
var (
	// ErrNotImplemented is returned when a method is not implemented.
	ErrNotImplemented = errors.New("not implemented")
)

Functions

This section is empty.

Types

type AgentService

type AgentService struct {
	// contains filtered or unexported fields
}

AgentService is a struct that implements the AgentUsecase interface.

func NewAgentService

func NewAgentService(
	agentPersistencePort port.AgentPersistencePort,
) *AgentService

NewAgentService creates a new instance of AgentService.

func (*AgentService) GetAgent

func (s *AgentService) GetAgent(ctx context.Context, instanceUID uuid.UUID) (*model.Agent, error)

GetAgent retrieves an agent by its instance UID.

func (*AgentService) GetOrCreateAgent

func (s *AgentService) GetOrCreateAgent(ctx context.Context, instanceUID uuid.UUID) (*model.Agent, error)

GetOrCreateAgent retrieves an agent by its instance UID.

func (*AgentService) ListAgents

func (s *AgentService) ListAgents(ctx context.Context) ([]*model.Agent, error)

ListAgents retrieves all agents from the persistence layer.

func (*AgentService) SaveAgent

func (s *AgentService) SaveAgent(ctx context.Context, agent *model.Agent) error

SaveAgent saves the agent to the persistence layer.

func (*AgentService) UpdateAgentConfig added in v0.0.2

func (s *AgentService) UpdateAgentConfig(ctx context.Context, instanceUID uuid.UUID, config any) error

UpdateAgentConfig updates the agent configuration.

type CommandService

type CommandService struct {
	// contains filtered or unexported fields
}

CommandService is a struct that implements the CommandUsecase interface.

func NewCommandService

func NewCommandService(
	commandPersistencePort port.CommandPersistencePort,
) *CommandService

NewCommandService creates a new instance of CommandService.

func (*CommandService) GetCommand

func (s *CommandService) GetCommand(ctx context.Context, commandID uuid.UUID) (*model.Command, error)

GetCommand retrieves a command by its ID.

func (*CommandService) GetCommandByInstanceUID

func (s *CommandService) GetCommandByInstanceUID(ctx context.Context, instanceUID uuid.UUID) ([]*model.Command, error)

GetCommandByInstanceUID retrieves a command by its instance UID.

func (*CommandService) ListCommands added in v0.0.2

func (s *CommandService) ListCommands(context.Context) ([]*model.Command, error)

ListCommands implements port.CommandUsecase.

func (*CommandService) SaveCommand

func (s *CommandService) SaveCommand(ctx context.Context, command *model.Command) error

SaveCommand saves the command to the persistence layer.

type ConnectionManager

type ConnectionManager struct {
	// contains filtered or unexported fields
}

ConnectionManager is a struct that manages connections. It uses a map to store connections and provides methods to save, get, update, and delete connections.

func NewConnectionManager

func NewConnectionManager() *ConnectionManager

NewConnectionManager creates a new instance of ConnectionManager.

func (*ConnectionManager) DeleteConnection

func (cm *ConnectionManager) DeleteConnection(id uuid.UUID) error

DeleteConnection deletes the connection by the given ID. It returns an error if the connection does not exist.

func (*ConnectionManager) FetchAndDeleteConnection

func (cm *ConnectionManager) FetchAndDeleteConnection(id uuid.UUID) (*model.Connection, error)

FetchAndDeleteConnection fetches the connection by the given ID and deletes it from the map. It returns the connection if it exists, otherwise it returns an error.

func (*ConnectionManager) GetConnection

func (cm *ConnectionManager) GetConnection(id uuid.UUID) (*model.Connection, error)

GetConnection returns the connection by the given ID.

func (*ConnectionManager) GetOrCreateConnection

func (cm *ConnectionManager) GetOrCreateConnection(instanceUID uuid.UUID) (*model.Connection, error)

GetOrCreateConnection returns the connection by the given ID. If the connection does not exist, it creates a new one and saves it to the map.

func (*ConnectionManager) ListAliveConnections

func (cm *ConnectionManager) ListAliveConnections() []*model.Connection

ListAliveConnections returns the list of alive connections.

func (*ConnectionManager) ListConnections

func (cm *ConnectionManager) ListConnections() []*model.Connection

ListConnections returns the list of connections.

func (*ConnectionManager) SaveConnection

func (cm *ConnectionManager) SaveConnection(connection *model.Connection) error

SaveConnection saves the connection to the map. It returns an error if the connection is nil or if the connection already exists.

Jump to

Keyboard shortcuts

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