From 050c087a516e5c0a35efa5b68dbfdcd930386b58 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Wed, 13 Nov 2024 08:03:10 +1000 Subject: [PATCH] Fix annoying joqqueue issue where jobs were blocked by unused channel --- backend/internal/jobqueue/main.go | 2 +- backend/internal/jobqueue/models.go | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/backend/internal/jobqueue/main.go b/backend/internal/jobqueue/main.go index 5609823a..22793186 100644 --- a/backend/internal/jobqueue/main.go +++ b/backend/internal/jobqueue/main.go @@ -16,7 +16,7 @@ var ( func Start() { ctx, cancel = context.WithCancel(context.Background()) q := &Queue{ - jobs: make(chan Job, 10), + jobs: make(chan Job, 50), ctx: ctx, cancel: cancel, } diff --git a/backend/internal/jobqueue/models.go b/backend/internal/jobqueue/models.go index dc959cd6..410a788f 100644 --- a/backend/internal/jobqueue/models.go +++ b/backend/internal/jobqueue/models.go @@ -17,7 +17,6 @@ type Queue struct { type Job struct { Name string Action func() error // A function that should be executed when the job is running. - Done chan bool // A channel that should be closed when the job is done. } // AddJobs adds jobs to the queue and cancels channel. @@ -49,12 +48,5 @@ func (q *Queue) AddJob(job Job) { // Run performs job execution. func (j *Job) Run() error { - err := j.Action() - if err != nil { - j.Done <- true - return err - } - - j.Done <- true - return nil + return j.Action() }