open question: should the methods on juju.Conn take a string or a type
Gustavo Niemeyer
gustavo at niemeyer.net
Tue Aug 7 13:58:43 UTC 2012
On Tue, Aug 7, 2012 at 2:28 PM, roger peppe <roger.peppe at canonical.com> wrote:
> I agree with Gustavo's sentiments. I thrashed through this issue
> when doing the recent deploy changes to Conn, and we decided
> that State was deliberately *not* hidden behind Conn
> (hence the AddService method which returns a *state.Service).
>
> I think to make things a little easier when using a Conn,
> we could have methods on Conn that convert from strings
> to the respective state type.
>
> For instance:
>
> // Service returns the service with the given name.
> func (c *Conn) Service(name string) (*state.Service, error)
>
> This has two advantages:
> 1) It makes the code slightly smaller in the command implementations.
> 2) It makes it obvious that state.Service is "blessed" with respect
> to the Conn type - that you are expected to deal with the underlying
> state.Service to get things done.
>
> Reasonable?
SGTM
It also sounds fine to have things like conn.Expose that offer
functionality that is obviously important for clients (hint: we have a
command for it). As you clearly explained, the goal isn't to
*hide* *State, though.
gustavo @ http://niemeyer.net
More information about the Juju-dev
mailing list