mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-21 21:03:22 +00:00
remove docker/queue singletons; inject in main
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
package queue
|
||||
|
||||
import (
|
||||
"github.com/drone/drone/pkg/build/docker"
|
||||
"github.com/drone/drone/pkg/build/script"
|
||||
. "github.com/drone/drone/pkg/model"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A Queue dispatches tasks to workers.
|
||||
@@ -25,10 +22,6 @@ type BuildTask struct {
|
||||
Script *script.Build
|
||||
}
|
||||
|
||||
var defaultQueue = Start(runtime.NumCPU(), newRunner(docker.DefaultClient, 300*time.Second)) // TEMPORARY; INJECT PLEASE
|
||||
|
||||
var Add = defaultQueue.Add // TEMPORARY; INJECT PLEASE
|
||||
|
||||
func Start(workers int, runner Runner) *Queue {
|
||||
// get the number of CPUs. Since builds
|
||||
// tend to be CPU-intensive we should only
|
||||
|
@@ -19,7 +19,7 @@ type runner struct {
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func newRunner(dockerClient *docker.Client, timeout time.Duration) *runner {
|
||||
func NewRunner(dockerClient *docker.Client, timeout time.Duration) Runner {
|
||||
return &runner{
|
||||
dockerClient: dockerClient,
|
||||
timeout: timeout,
|
||||
|
Reference in New Issue
Block a user