~rogpeppe/juju-core/256-more-status

« back to all changes in this revision

Viewing changes to state/statecmd/destroyunit.go

statecmd: don't use juju.Conn unnecessarily

There's an associated cost when the API uses juju.Conn,
so we want to avoid it when reasonable.
This change moves some operations from juju into
state because they don't require juju.Conn's associated
Environ.

R=fwereade, dimitern
CC=
https://codereview.appspot.com/7945044

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
package statecmd
4
4
 
5
5
import (
6
 
        "launchpad.net/juju-core/juju"
7
6
        "launchpad.net/juju-core/state"
8
7
        "launchpad.net/juju-core/state/api/params"
9
8
)
10
9
 
11
10
// DestroyServiceUnits removes the specified units.
12
 
func DestroyServiceUnits(state *state.State, args params.DestroyServiceUnits) error {
13
 
        conn, err := juju.NewConnFromState(state)
14
 
        if err != nil {
15
 
                return err
16
 
        }
17
 
        return conn.DestroyUnits(args.UnitNames...)
 
11
func DestroyServiceUnits(st *state.State, args params.DestroyServiceUnits) error {
 
12
        return st.DestroyUnits(args.UnitNames...)
18
13
}