Documentation
¶
Index ¶
- Variables
- type Manager
- func (m *Manager) Cleanup(maxAge time.Duration)
- func (m *Manager) Create(cmd *exec.Cmd, command, description string, ctx context.Context, ...) *Task
- func (m *Manager) Get(id string) (*Task, bool)
- func (m *Manager) Kill(id string) error
- func (m *Manager) List() []*Task
- func (m *Manager) ListRunning() []*Task
- func (m *Manager) Remove(id string)
- type Task
- type TaskInfo
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultManager = NewManager()
DefaultManager is the global default task manager
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages background tasks
func (*Manager) Create ¶
func (m *Manager) Create(cmd *exec.Cmd, command, description string, ctx context.Context, cancel context.CancelFunc) *Task
Create creates and registers a new task
func (*Manager) ListRunning ¶
ListRunning returns all running tasks
type Task ¶
type Task struct {
ID string // Unique task ID
Command string // The command being executed
Description string // Brief description
Status TaskStatus // Current status
PID int // Process ID
StartTime time.Time // When the task started
EndTime time.Time // When the task ended (if completed)
ExitCode int // Exit code (if completed)
Error string // Error message (if failed)
Cmd *exec.Cmd // The running command
Ctx context.Context // Task context
Cancel context.CancelFunc // Cancel function
// contains filtered or unexported fields
}
Task represents a background task
func NewTask ¶
func NewTask(id, command, description string, cmd *exec.Cmd, ctx context.Context, cancel context.CancelFunc) *Task
NewTask creates a new task
func (*Task) AppendOutput ¶
AppendOutput appends data to the output buffer
type TaskInfo ¶
type TaskInfo struct {
ID string
Command string
Description string
Status TaskStatus
PID int
StartTime time.Time
EndTime time.Time
ExitCode int
Error string
Output string
}
TaskInfo is a snapshot of task information
type TaskStatus ¶
type TaskStatus string
TaskStatus represents the status of a background task
const ( StatusRunning TaskStatus = "running" StatusCompleted TaskStatus = "completed" StatusFailed TaskStatus = "failed" StatusKilled TaskStatus = "killed" )
Click to show internal directories.
Click to hide internal directories.