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

2
go.mod
View File

@@ -8,6 +8,7 @@ require (
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/marcboeker/go-duckdb/v2 v2.4.3
golang.org/x/crypto v0.45.0
golang.org/x/oauth2 v0.33.0
)
@@ -29,7 +30,6 @@ require (
github.com/marcboeker/go-duckdb/mapping v0.0.21 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/mod v0.27.0 // indirect
golang.org/x/sync v0.16.0 // indirect

2
go.sum
View File

@@ -74,8 +74,6 @@ golang.org/x/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo=
golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=

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)