Descriptionstate/api/watcher: Refactor API watchers
This moves the state/api/watcher.go file into state/api/watcher/watcher.go. The
main benefit of that is to avoid circular imports as we start having APIs
themselves returning Watcher objects.
In doing that move I found a few things:
1) We needed api.ErrCode for a few things, so it got moved to params.ErrCode,
which caused some small duplication with the existing params.Errors. However,
they were pratically identical (apierrors.go had a GoString that params.Errors
didn't have.)
2) Most callers that were calling api.ErrCode already had imported params anyway.
3) AllWatcher is very entwined with its Client, so I didn't move that specific
part of the code. (Client can return an AllWatcher, and AllWatcher points to
its Client.)
4) I changed the Watcher code so it needs a Caller rather than an api.State.
The only thing any of the code did was call .Call anyway, which means we have a
nice opportunity that we could mock out actual calls to the remote State api if
we want some tighter testing of the client-side code.
So I like switching to a simple interface. I'm not sure about that being a
"Caller" interface because that seems a bit generic.
5) api.params.NotifyWatcher implements the same interface as
state.NotifyWatcher. So we can be reasonably confident that code that was using
an existing watcher will be compatible. Yay.
https://code.launchpad.net/~jameinel/juju-core/api-watchers/+merge/173035
(do not edit description out of merge proposal)
Patch Set 1 #
Total comments: 14
Patch Set 2 : state/api/watcher: Refactor API watchers #Patch Set 3 : state/api/watcher: Refactor API watchers #Patch Set 4 : state/api/watcher: Refactor API watchers #
Total comments: 5
Patch Set 5 : state/api/watcher: Refactor API watchers #
Total comments: 16
Patch Set 6 : state/api/watcher: Refactor API watchers #
MessagesTotal messages: 9
|