Skip to content

Commit 050c087

Browse files
committed
Fix annoying joqqueue issue where jobs were blocked by unused channel
1 parent 61c41b8 commit 050c087

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

backend/internal/jobqueue/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var (
1616
func Start() {
1717
ctx, cancel = context.WithCancel(context.Background())
1818
q := &Queue{
19-
jobs: make(chan Job, 10),
19+
jobs: make(chan Job, 50),
2020
ctx: ctx,
2121
cancel: cancel,
2222
}

backend/internal/jobqueue/models.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Queue struct {
1717
type Job struct {
1818
Name string
1919
Action func() error // A function that should be executed when the job is running.
20-
Done chan bool // A channel that should be closed when the job is done.
2120
}
2221

2322
// AddJobs adds jobs to the queue and cancels channel.
@@ -49,12 +48,5 @@ func (q *Queue) AddJob(job Job) {
4948

5049
// Run performs job execution.
5150
func (j *Job) Run() error {
52-
err := j.Action()
53-
if err != nil {
54-
j.Done <- true
55-
return err
56-
}
57-
58-
j.Done <- true
59-
return nil
51+
return j.Action()
6052
}

0 commit comments

Comments
 (0)