Created interfaces package to break tight coupling: 1. internal/worker/interfaces/executor.go (30 lines) - JobExecutor interface for job execution - ExecutionEnv struct for execution context - ExecutionResult struct for results 2. internal/worker/interfaces/tracker.go (20 lines) - ProgressTracker interface for execution stages - StageStart, StageComplete, StageFailed methods - JobComplete for final status 3. internal/worker/interfaces/manifest.go (18 lines) - ManifestWriter interface for manifest operations - Upsert method for update/create - BuildInitial method for creating new manifests These interfaces will enable: - Dependency injection in future phases - Mocking for unit tests - Clean separation between orchestration and execution Build status: Compiles successfully
33 lines
766 B
Go
33 lines
766 B
Go
// Package interfaces defines the contracts for worker components
|
|
package interfaces
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/jfraeys/fetch_ml/internal/queue"
|
|
)
|
|
|
|
// ExecutionEnv holds the environment for job execution
|
|
type ExecutionEnv struct {
|
|
JobDir string
|
|
OutputDir string
|
|
LogFile string
|
|
GPUDevices []string
|
|
GPUEnvVar string
|
|
GPUDevicesStr string
|
|
}
|
|
|
|
// JobExecutor defines the contract for executing jobs
|
|
type JobExecutor interface {
|
|
// Execute runs a job with the given context, task, and environment
|
|
Execute(ctx context.Context, task *queue.Task, env ExecutionEnv) error
|
|
}
|
|
|
|
// ExecutionResult holds the result of job execution
|
|
type ExecutionResult struct {
|
|
Success bool
|
|
ExitCode int
|
|
Duration time.Duration
|
|
Error error
|
|
}
|