Documentation
¶
Overview ¶
Package service provides the service layer for the opampcommander application.
Index ¶
- Variables
- type AgentService
- func (s *AgentService) GetAgent(ctx context.Context, instanceUID uuid.UUID) (*model.Agent, error)
- func (s *AgentService) GetOrCreateAgent(ctx context.Context, instanceUID uuid.UUID) (*model.Agent, error)
- func (s *AgentService) ListAgents(ctx context.Context) ([]*model.Agent, error)
- func (s *AgentService) SaveAgent(ctx context.Context, agent *model.Agent) error
- func (s *AgentService) UpdateAgentConfig(ctx context.Context, instanceUID uuid.UUID, config any) error
- type CommandService
- func (s *CommandService) GetCommand(ctx context.Context, commandID uuid.UUID) (*model.Command, error)
- func (s *CommandService) GetCommandByInstanceUID(ctx context.Context, instanceUID uuid.UUID) ([]*model.Command, error)
- func (s *CommandService) ListCommands(context.Context) ([]*model.Command, error)
- func (s *CommandService) SaveCommand(ctx context.Context, command *model.Command) error
- type ConnectionManager
- func (cm *ConnectionManager) DeleteConnection(id uuid.UUID) error
- func (cm *ConnectionManager) FetchAndDeleteConnection(id uuid.UUID) (*model.Connection, error)
- func (cm *ConnectionManager) GetConnection(id uuid.UUID) (*model.Connection, error)
- func (cm *ConnectionManager) GetOrCreateConnection(instanceUID uuid.UUID) (*model.Connection, error)
- func (cm *ConnectionManager) ListAliveConnections() []*model.Connection
- func (cm *ConnectionManager) ListConnections() []*model.Connection
- func (cm *ConnectionManager) SaveConnection(connection *model.Connection) error
Constants ¶
This section is empty.
Variables ¶
var ErrNilArgument = errors.New("argument is nil")
ErrNilArgument is an error that indicates that the argument passed to a function is nil.
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) 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 ¶
ListAgents retrieves all agents from 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
ListCommands implements port.CommandUsecase.
func (*CommandService) SaveCommand ¶
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.