func newStringsHandlerWorker(c *gc.C, setupError, handlerError, teardownError error) (*stringsHandler, worker.Worker) { sh := &stringsHandler{ actions: nil, handled: make(chan []string, 1), setupError: setupError, teardownError: teardownError, handlerError: handlerError, watcher: &testStringsWatcher{ changes: make(chan []string), }, setupDone: make(chan struct{}), } w := legacy.NewStringsWorker(sh) select { case <-sh.setupDone: case <-time.After(coretesting.ShortWait): c.Error("Failed waiting for stringsHandler.Setup to be called during SetUpTest") } return sh, w }
// 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 legacy.NewStringsWorker(mu) }