taskqueue

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package taskqueue provides task handover queue management.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTaskNotFound is returned when a task is not found.
	ErrTaskNotFound = errors.New("task not found")
	// ErrTaskAlreadyExists is returned when adding a task that already exists.
	ErrTaskAlreadyExists = errors.New("task already exists")
)

Functions

This section is empty.

Types

type HandoverEvent

type HandoverEvent struct {
	Timestamp time.Time `json:"timestamp"`
	Event     string    `json:"event"`
	From      string    `json:"from,omitempty"`
	To        string    `json:"to,omitempty"`
	Reason    string    `json:"reason,omitempty"`
}

HandoverEvent represents a single event in the handover history.

type HandoverStatus

type HandoverStatus string

HandoverStatus represents the status of a pending task.

const (
	// HandoverStatusPending indicates the task is waiting for reassignment.
	HandoverStatusPending HandoverStatus = "pending"
	// HandoverStatusAssigned indicates the task has been assigned to another agent.
	HandoverStatusAssigned HandoverStatus = "assigned"
	// HandoverStatusCompleted indicates the handover was completed successfully.
	HandoverStatusCompleted HandoverStatus = "completed"
	// HandoverStatusFailed indicates the handover failed.
	HandoverStatusFailed HandoverStatus = "failed"
)

type MemoryStore

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

MemoryStore provides an in-memory implementation of TaskStore. Phase 1 implementation - tasks are lost on restart.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new in-memory task store.

func (*MemoryStore) Add

func (s *MemoryStore) Add(task PendingTask) error

Add adds a task to the store.

func (*MemoryStore) Clear

func (s *MemoryStore) Clear()

Clear removes all tasks from the store.

func (*MemoryStore) Count

func (s *MemoryStore) Count() int

Count returns the number of tasks in the store.

func (*MemoryStore) Get

func (s *MemoryStore) Get(issueNumber int) (*PendingTask, error)

Get retrieves a task by issue number.

func (*MemoryStore) List

func (s *MemoryStore) List() ([]PendingTask, error)

List returns all tasks sorted by priority (higher first) and creation time.

func (*MemoryStore) Remove

func (s *MemoryStore) Remove(issueNumber int) error

Remove removes a task from the store.

func (*MemoryStore) Update

func (s *MemoryStore) Update(task PendingTask) error

Update updates a task in the store.

type PendingTask

type PendingTask struct {
	IssueNumber    int             `json:"issue_number"`
	OriginalAgent  string          `json:"original_agent"`
	AssignedAgent  string          `json:"assigned_agent,omitempty"`
	Context        string          `json:"context,omitempty"`
	ContextSummary string          `json:"context_summary,omitempty"`
	Priority       int             `json:"priority"`
	Status         HandoverStatus  `json:"status"`
	CreatedAt      time.Time       `json:"created_at"`
	History        []HandoverEvent `json:"history,omitempty"`
}

PendingTask represents a task waiting for handover.

type Queue

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

Queue manages pending tasks with thread-safe operations.

func NewQueue

func NewQueue(store TaskStore) *Queue

NewQueue creates a new task queue with the given store.

func (*Queue) Add

func (q *Queue) Add(task PendingTask) error

Add adds a new pending task to the queue.

func (*Queue) Assign

func (q *Queue) Assign(issueNumber int, targetAgent string) error

Assign assigns a pending task to a new agent.

func (*Queue) Complete

func (q *Queue) Complete(issueNumber int) error

Complete marks a task as completed.

func (*Queue) Fail

func (q *Queue) Fail(issueNumber int, reason string) error

Fail marks a task as failed.

func (*Queue) Get

func (q *Queue) Get(issueNumber int) (*PendingTask, error)

Get retrieves a task by issue number.

func (*Queue) List

func (q *Queue) List() ([]PendingTask, error)

List returns all pending tasks.

func (*Queue) ListPending

func (q *Queue) ListPending() ([]PendingTask, error)

ListPending returns only tasks with pending status.

func (*Queue) Remove

func (q *Queue) Remove(issueNumber int) error

Remove removes a task from the queue.

type TaskStore

type TaskStore interface {
	// Add adds a task to the queue.
	Add(task PendingTask) error
	// Get retrieves a task by issue number.
	Get(issueNumber int) (*PendingTask, error)
	// List returns all pending tasks.
	List() ([]PendingTask, error)
	// Update updates a task in the queue.
	Update(task PendingTask) error
	// Remove removes a task from the queue.
	Remove(issueNumber int) error
}

TaskStore defines the interface for task storage. Phase 1: MemoryStore implementation Phase 2: FileStore implementation (future)

Jump to

Keyboard shortcuts

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