Update go.mod to include golang.org/x/crypto v0.45.0 and remove indirect reference. Refactor task handling in client.go to use switch-case for task types and remove unused VAAPI device functions for cleaner code.

This commit is contained in:
2025-11-23 11:03:54 -06:00
parent 2a0ff98834
commit f7e1766d8b
3 changed files with 8 additions and 54 deletions

View File

@@ -646,16 +646,17 @@ func (c *Client) handleTaskAssignment(msg map[string]interface{}) {
// Process the task based on type
go func() {
var err error
if taskType == "metadata" {
switch taskType {
case "metadata":
if len(inputFilesRaw) == 0 {
log.Printf("No input files for metadata task %v", taskID)
c.sendTaskComplete(int64(taskID), "", false, "No input files")
return
}
err = c.processMetadataTask(taskMap, int64(jobID), inputFilesRaw)
} else if taskType == "video_generation" {
case "video_generation":
err = c.processVideoGenerationTask(taskMap, int64(jobID))
} else {
default:
if len(inputFilesRaw) == 0 {
errMsg := fmt.Sprintf("No input files provided for task %d (job %d). Task assignment data: job_name=%s, output_format=%s, task_type=%s",
int64(taskID), int64(jobID), jobName, outputFormat, taskType)
@@ -941,7 +942,9 @@ func (c *Client) sendStepUpdate(taskID int64, stepName string, status types.Step
}
// processTask processes a single task
func (c *Client) processTask(task map[string]interface{}, jobName, outputFormat string, inputFiles []interface{}) error {
func (c *Client) processTask(task map[string]interface{}, jobName string, outputFormat string, inputFiles []interface{}) error {
_ = jobName
taskID := int64(task["id"].(float64))
jobID := int64(task["job_id"].(float64))
frameStart := int(task["frame_start"].(float64))
@@ -2248,12 +2251,6 @@ func (c *Client) getVAAPIDevice() string {
return ""
}
// getAllVAAPIDevices returns all available VAAPI devices
// This can be useful for logging, diagnostics, or future multi-device support
func (c *Client) getAllVAAPIDevices() []string {
return c.findVAAPIDevices()
}
// allocateVAAPIDevice allocates an available VAAPI device to a task
// Returns the device path, or empty string if no device is available
func (c *Client) allocateVAAPIDevice(taskID int64) string {
@@ -2306,25 +2303,6 @@ func (c *Client) releaseVAAPIDevice(taskID int64) {
}
}
// getVAAPIDeviceAllocationStatus returns information about device allocation
// Returns: total devices, allocated devices, available devices
func (c *Client) getVAAPIDeviceAllocationStatus() (total int, allocated int, available int) {
c.allocatedDevicesMu.RLock()
defer c.allocatedDevicesMu.RUnlock()
allDevices := c.findVAAPIDevices()
total = len(allDevices)
if c.allocatedDevices == nil {
allocated = 0
} else {
allocated = len(c.allocatedDevices)
}
available = total - allocated
return
}
// testQSVEncoder tests Intel Quick Sync Video encoder
func (c *Client) testQSVEncoder() bool {
// QSV can work with different backends
@@ -2537,28 +2515,6 @@ func extractFrameNumber(filename string) int {
return frameNum
}
// getJobStatus gets job status from manager
func (c *Client) getJobStatus(jobID int64) (map[string]interface{}, error) {
path := fmt.Sprintf("/api/runner/jobs/%d/status", jobID)
resp, err := c.doSignedRequest("GET", path, nil, fmt.Sprintf("runner_id=%d", c.runnerID))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("failed to get job status: %s", string(body))
}
var job map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&job); err != nil {
return nil, err
}
return job, nil
}
// getJobFiles gets job files from manager
func (c *Client) getJobFiles(jobID int64) ([]map[string]interface{}, error) {
path := fmt.Sprintf("/api/runner/jobs/%d/files", jobID)