Documentation
¶
Overview ¶
Package queue provides persistent operation queuing for disconnected scenarios. Operations are queued to disk and executed when connectivity is restored.
Index ¶
- type Operation
- type OperationResult
- type OperationState
- type Queue
- func (q *Queue) Cancel(opID string) error
- func (q *Queue) Clear() error
- func (q *Queue) Close() error
- func (q *Queue) Complete(opID string, result *OperationResult) error
- func (q *Queue) Dequeue() *Operation
- func (q *Queue) Enqueue(op *Operation) error
- func (q *Queue) Fail(opID string, err error) error
- func (q *Queue) Get(opID string) (*Operation, error)
- func (q *Queue) IsExecuting(opID string) bool
- func (q *Queue) List(filter *OperationState) []*Operation
- func (q *Queue) MarkExecuting(opID string)
- func (q *Queue) PendingCount() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operation ¶
type Operation struct {
ID string `json:"id"`
Type string `json:"type"`
AgentID string `json:"agent_id"`
Payload map[string]interface{} `json:"payload"`
CreatedAt time.Time `json:"created_at"`
Attempts int `json:"attempts"`
MaxRetry int `json:"max_retry"`
State OperationState `json:"state"`
Result *OperationResult `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
Operation represents a queued operation to be executed when connected
type OperationResult ¶
type OperationResult struct {
Success bool `json:"success"`
Data map[string]interface{} `json:"data,omitempty"`
Duration time.Duration `json:"duration"`
}
OperationResult holds the result of an executed operation
type OperationState ¶
type OperationState string
OperationState represents the state of a queued operation
const ( StatePending OperationState = "pending" StateExecuting OperationState = "executing" StateCompleted OperationState = "completed" StateFailed OperationState = "failed" StateCancelled OperationState = "cancelled" )
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue manages persistent operation queuing
func (*Queue) Complete ¶
func (q *Queue) Complete(opID string, result *OperationResult) error
Complete marks an operation as completed
func (*Queue) IsExecuting ¶
IsExecuting returns true if an operation is currently executing
func (*Queue) List ¶
func (q *Queue) List(filter *OperationState) []*Operation
List returns all operations, optionally filtered by state
func (*Queue) MarkExecuting ¶
MarkExecuting marks an operation as executing
func (*Queue) PendingCount ¶
PendingCount returns the number of pending operations