remove docker/queue singletons; inject in main

This commit is contained in:
Alex Suraci
2014-02-25 17:10:04 -08:00
parent c0adf459f9
commit 9e1c4e60e5
6 changed files with 29 additions and 19 deletions

View File

@@ -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

View File

@@ -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,