-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
42 lines (37 loc) · 1.07 KB
/
interface.go
File metadata and controls
42 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package task_engine
import (
"context"
"time"
)
// TaskManagerInterface defines the contract for task management
type TaskManagerInterface interface {
AddTask(task *Task) error
RunTask(taskID string) (*TaskHandle, error)
StopTask(taskID string) error
StopAllTasks()
GetRunningTasks() []string
IsTaskRunning(taskID string) bool
GetGlobalContext() *GlobalContext
ResetGlobalContext()
}
// TaskInterface defines the contract for individual tasks
type TaskInterface interface {
GetID() string
GetName() string
Run(ctx context.Context) error
RunWithContext(ctx context.Context, globalContext *GlobalContext) error
GetCompletedTasks() int
GetTotalTime() time.Duration
}
// ResultProvider interface for tasks that produce results
type ResultProvider interface {
GetResult() interface{}
GetError() error
}
// TaskWithResults interface for tasks that can optionally provide rich results
// Combines the task lifecycle with the ability to provide results and errors
// after execution, mirroring ActionWithResults.
type TaskWithResults interface {
TaskInterface
ResultProvider
}