Queue Enable
All checks were successful
/ release (push) Successful in 42s

This commit is contained in:
Samuel Lorch 2024-07-06 18:01:51 +02:00
parent 77d7a8624c
commit b03e85db0b
7 changed files with 77 additions and 2 deletions

View file

@ -371,8 +371,18 @@ func assignQueuedTasks(ctx context.Context) error {
return nil
}
if Workers[i].Connected {
var queueEnable bool
err := db.QueryRow(ctx, "SELECT queue_enable FROM workers WHERE id = $1", i).Scan(&queueEnable)
if err != nil {
return fmt.Errorf("Error Querying Worker Queue Enable: %w", err)
}
if !queueEnable {
slog.DebugContext(ctx, "Skipping Worker since Queueing is disabled", "worker_id", i)
continue
}
var count int
err := db.QueryRow(ctx, "SELECT COUNT(*) FROM tasks WHERE worker_id = $1 AND (status = $2 OR status = $3 OR status = $4 OR status = $5)", i, constants.TASK_STATUS_UNKNOWN, constants.TASK_STATUS_ASSIGNED, constants.TASK_STATUS_RUNNING, constants.TASK_STATUS_WAITING).Scan(&count)
err = db.QueryRow(ctx, "SELECT COUNT(*) FROM tasks WHERE worker_id = $1 AND (status = $2 OR status = $3 OR status = $4 OR status = $5)", i, constants.TASK_STATUS_UNKNOWN, constants.TASK_STATUS_ASSIGNED, constants.TASK_STATUS_RUNNING, constants.TASK_STATUS_WAITING).Scan(&count)
if err != nil {
return fmt.Errorf("Error Querying Worker Task Count: %w", err)
}