コード例 #1
0
ファイル: environ.go プロジェクト: hivetech/judo.legacy
// WaitForEnviron waits for an valid environment to arrive from
// the given watcher. It terminates with tomb.ErrDying if
// it receives a value on dying.
func WaitForEnviron(w *state.EnvironConfigWatcher, dying <-chan struct{}) (environs.Environ, error) {
	for {
		select {
		case <-dying:
			return nil, tomb.ErrDying
		case config, ok := <-w.Changes():
			if !ok {
				return nil, watcher.MustErr(w)
			}
			environ, err := environs.New(config)
			if err == nil {
				return environ, nil
			}
			log.Errorf("worker: loaded invalid environment configuration: %v", err)
			loadedInvalid()
		}
	}
}
コード例 #2
0
ファイル: environ_test.go プロジェクト: prabhakhar/juju-core
func stopWatcher(c *C, w *state.EnvironConfigWatcher) {
	err := w.Stop()
	c.Check(err, IsNil)
}