Documentation
¶
Index ¶
- type CompleteInput
- type CreateInput
- type ExpirationChecker
- type ExpirationCheckerConfig
- type FailInput
- type ListInput
- type PollInput
- type Service
- func (s *Service) Acknowledge(ctx context.Context, tenantID, commandID string) (*commanddom.Command, error)
- func (s *Service) CancelCommand(ctx context.Context, tenantID, commandID string) (*commanddom.Command, error)
- func (s *Service) Complete(ctx context.Context, input CompleteInput) (*commanddom.Command, error)
- func (s *Service) Create(ctx context.Context, input CreateInput) (*commanddom.Command, error)
- func (s *Service) DeleteCommand(ctx context.Context, tenantID, commandID string) error
- func (s *Service) ExpireOldCommands(ctx context.Context) (int64, error)
- func (s *Service) Fail(ctx context.Context, input FailInput) (*commanddom.Command, error)
- func (s *Service) Get(ctx context.Context, tenantID, commandID string) (*commanddom.Command, error)
- func (s *Service) List(ctx context.Context, input ListInput) (pagination.Result[*commanddom.Command], error)
- func (s *Service) Poll(ctx context.Context, input PollInput) ([]*commanddom.Command, error)
- func (s *Service) Start(ctx context.Context, tenantID, commandID string) (*commanddom.Command, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompleteInput ¶
type CompleteInput struct {
TenantID string `json:"tenant_id" validate:"required,uuid"`
CommandID string `json:"command_id" validate:"required,uuid"`
Result json.RawMessage `json:"result,omitempty"`
}
CompleteInput represents the input for completing a command.
type CreateInput ¶
type CreateInput struct {
TenantID string `json:"tenant_id" validate:"required,uuid"`
AgentID string `json:"agent_id,omitempty" validate:"omitempty,uuid"`
Type string `json:"type" validate:"required,oneof=scan collect health_check config_update cancel"`
Priority string `json:"priority" validate:"omitempty,oneof=low normal high critical"`
Payload json.RawMessage `json:"payload,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"` // Seconds until expiration
}
CreateInput represents the input for creating a command.
type ExpirationChecker ¶
type ExpirationChecker struct {
// contains filtered or unexported fields
}
ExpirationChecker periodically checks for expired commands and handles them.
func NewExpirationChecker ¶
func NewExpirationChecker( commandRepo commanddom.Repository, pipelineService *pipeline.Service, cfg ExpirationCheckerConfig, log *logger.Logger, ) *ExpirationChecker
NewExpirationChecker creates a new ExpirationChecker.
func (*ExpirationChecker) Start ¶
func (c *ExpirationChecker) Start()
Start starts the command expiration checker.
func (*ExpirationChecker) Stop ¶
func (c *ExpirationChecker) Stop()
Stop stops the command expiration checker gracefully.
type ExpirationCheckerConfig ¶
type ExpirationCheckerConfig struct {
// CheckInterval is how often to check for expired commands (default: 1 minute)
CheckInterval time.Duration
}
ExpirationCheckerConfig holds configuration for the command expiration checker.
type FailInput ¶
type FailInput struct {
TenantID string `json:"tenant_id" validate:"required,uuid"`
CommandID string `json:"command_id" validate:"required,uuid"`
ErrorMessage string `json:"error_message"`
}
FailInput represents the input for failing a command.
type ListInput ¶
type ListInput struct {
TenantID string `json:"tenant_id" validate:"required,uuid"`
AgentID string `json:"agent_id,omitempty" validate:"omitempty,uuid"`
Type string `json:"type" validate:"omitempty,oneof=scan collect health_check config_update cancel"`
Status string `json:"status" validate:"omitempty,oneof=pending acknowledged running completed failed canceled expired"`
Priority string `json:"priority" validate:"omitempty,oneof=low normal high critical"`
Page int `json:"page"`
PerPage int `json:"per_page"`
}
ListInput represents the input for listing commands.
type PollInput ¶
type PollInput struct {
TenantID string `json:"tenant_id" validate:"required,uuid"`
AgentID string `json:"agent_id,omitempty" validate:"omitempty,uuid"`
Limit int `json:"limit" validate:"min=1,max=100"`
}
PollInput represents the input for polling commands.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles command-related business operations.
func NewService ¶
func NewService(repo commanddom.Repository, log *logger.Logger) *Service
NewService creates a new Service.
func (*Service) Acknowledge ¶
func (s *Service) Acknowledge(ctx context.Context, tenantID, commandID string) (*commanddom.Command, error)
Acknowledge marks a command as acknowledged.
func (*Service) CancelCommand ¶
func (s *Service) CancelCommand(ctx context.Context, tenantID, commandID string) (*commanddom.Command, error)
CancelCommand marks a command as canceled.
func (*Service) Complete ¶
func (s *Service) Complete(ctx context.Context, input CompleteInput) (*commanddom.Command, error)
Complete marks a command as completed.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, input CreateInput) (*commanddom.Command, error)
Create creates a new command.
func (*Service) DeleteCommand ¶
DeleteCommand deletes a command.
func (*Service) ExpireOldCommands ¶
ExpireOldCommands expires old pending commands.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, input ListInput) (pagination.Result[*commanddom.Command], error)
List lists commands with filters.