コード例 #1
0
ファイル: deployer.go プロジェクト: hivetech/judo.legacy
// NewDeployer returns a Worker that deploys and recalls unit agents
// via ctx, taking a machine id to operate on.
func NewDeployer(st *apideployer.State, ctx Context, machineTag string) worker.Worker {
	d := &Deployer{
		st:         st,
		ctx:        ctx,
		machineTag: machineTag,
	}
	return worker.NewStringsWorker(d)
}
コード例 #2
0
func (s *stringsWorkerSuite) SetUpTest(c *gc.C) {
	s.LoggingSuite.SetUpTest(c)
	s.actor = &stringsHandler{
		actions: nil,
		handled: make(chan []string, 1),
		watcher: &testStringsWatcher{
			changes: make(chan []string),
		},
	}
	s.worker = worker.NewStringsWorker(s.actor)
}
コード例 #3
0
func (s *stringsWorkerSuite) TestHandleErrorStopsWorkerAndWatcher(c *gc.C) {
	s.stopWorker(c)
	actor := &stringsHandler{
		actions:      nil,
		handled:      make(chan []string, 1),
		handlerError: fmt.Errorf("my handling error"),
		watcher: &testStringsWatcher{
			changes: make(chan []string),
		},
	}
	w := worker.NewStringsWorker(actor)
	actor.watcher.TriggerChange(c, []string{"aa", "bb"})
	waitForHandledStrings(c, actor.handled, []string{"aa", "bb"})
	err := waitShort(c, w)
	c.Check(err, gc.ErrorMatches, "my handling error")
	actor.CheckActions(c, "setup", "handler", "teardown")
	c.Check(actor.watcher.stopped, jc.IsTrue)
}
コード例 #4
0
func (s *stringsWorkerSuite) TestSetUpFailureStopsWithTearDown(c *gc.C) {
	// Stop the worker and SetUp again, this time with an error
	s.stopWorker(c)
	actor := &stringsHandler{
		actions:    nil,
		handled:    make(chan []string, 1),
		setupError: fmt.Errorf("my special error"),
		watcher: &testStringsWatcher{
			changes: make(chan []string),
		},
	}
	w := worker.NewStringsWorker(actor)
	err := waitShort(c, w)
	c.Check(err, gc.ErrorMatches, "my special error")
	// TearDown is not called on SetUp error.
	actor.CheckActions(c, "setup")
	c.Check(actor.watcher.stopped, jc.IsTrue)
}
コード例 #5
0
// NewMinUnitsWorker returns a Worker that runs service.EnsureMinUnits()
// if the number of alive units belonging to a service decreases, or if the
// minimum required number of units for a service is increased.
func NewMinUnitsWorker(st *state.State) worker.Worker {
	mu := &MinUnitsWorker{st: st}
	return worker.NewStringsWorker(mu)
}