コード例 #1
0
ファイル: timebomb.go プロジェクト: vito/warden-docker
func New(countdown time.Duration, detonate func()) *TimeBomb {
	return &TimeBomb{
		countdown: countdown,
		detonate:  detonate,

		reset:    make(chan bool),
		defuse:   make(chan bool),
		cooldown: drain.New(),
	}
}
コード例 #2
0
ファイル: server.go プロジェクト: vito/warden-docker
func New(
	listenNetwork, listenAddr string,
	containerGraceTime time.Duration,
	backend warden.Backend,
) *WardenServer {
	return &WardenServer{
		listenNetwork: listenNetwork,
		listenAddr:    listenAddr,

		containerGraceTime: containerGraceTime,
		backend:            backend,

		setStopping: make(chan bool),
		stopping:    make(chan bool),

		openRequests: drain.New(),
	}
}
コード例 #3
0
ファイル: drain_test.go プロジェクト: vito/warden-docker
package drain_test

import (
	"time"

	. "github.com/onsi/ginkgo"

	"github.com/cloudfoundry-incubator/garden/drain"
)

var _ = Describe("Drain", func() {
	Describe(".Wait", func() {
		It("returns immediately", func(done Done) {
			drain := drain.New()
			drain.Wait()
			close(done)
		}, 1.0)
	})

	Describe(".Incr", func() {
		Describe(".Wait", func() {
			It("blocks", func() {
				drain := drain.New()
				drain.Incr()

				waited := make(chan bool)

				go func() {
					drain.Wait()
					waited <- true
				}()