Configurable background task execution

This commit is contained in:
Lorenzo Bolla
2021-09-08 15:50:54 +02:00
parent bd4c3a246d
commit 9b28d8984f
18 changed files with 427 additions and 214 deletions
+9 -7
View File
@@ -1,6 +1,7 @@
package task
import (
"github.com/aptly-dev/aptly/aptly"
"sync/atomic"
)
@@ -20,7 +21,7 @@ type PublishDetail struct {
}
// Process is a function implementing the actual task logic
type Process func(out *Output, detail *Detail) error
type Process func(out aptly.Progress, detail *Detail) (int, error)
const (
// IDLE when task is waiting
@@ -35,12 +36,13 @@ const (
// Task represents as task in a queue encapsulates process code
type Task struct {
output *Output
detail *Detail
process Process
Name string
ID int
State State
output *Output
detail *Detail
process Process
processReturnCode int
Name string
ID int
State State
}
// NewTask creates new task