Ejemplo n.º 1
0
Archivo: life.go Proyecto: jiasir/juju
// Life requests the life cycle of the given entity from the given
// server-side API facade via the given caller.
func Life(caller base.Caller, facadeName string, tag names.Tag) (params.Life, error) {
	var result params.LifeResults
	args := params.Entities{
		Entities: []params.Entity{{Tag: tag.String()}},
	}
	if err := caller.Call(facadeName, "", "Life", args, &result); err != nil {
		return "", err
	}
	if len(result.Results) != 1 {
		return "", errors.Errorf("expected 1 result, got %d", len(result.Results))
	}
	if err := result.Results[0].Error; err != nil {
		return "", err
	}
	return result.Results[0].Life, nil
}
Ejemplo n.º 2
0
Archivo: watch.go Proyecto: jiasir/juju
// Watch starts a NotifyWatcher for the entity with the specified tag.
func Watch(caller base.Caller, facadeName string, tag names.Tag) (watcher.NotifyWatcher, error) {
	var results params.NotifyWatchResults
	args := params.Entities{
		Entities: []params.Entity{{Tag: tag.String()}},
	}
	err := caller.Call(facadeName, "", "Watch", args, &results)
	if err != nil {
		return nil, err
	}
	if len(results.Results) != 1 {
		return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results))
	}
	result := results.Results[0]
	if result.Error != nil {
		return nil, result.Error
	}
	return watcher.NewNotifyWatcher(caller, result), nil
}