juju/juju — pull request #98 by jameinel (2014-06-15 10:57:07+00:00)
Title: Introduce the ability to register Facades and have them exposed

This is work based on my github.com/jameinel/juju/api-versioning change.
See the incremental diff here: https://github.com/jameinel/juju/pull/1
It is probably better to do comments there, since it will be easier to not get confused about extra changes.

This updates the code around srvRoot so that we have a new state/apiserver/common.Facades registry and some convenience functions for API facades to register themselves.
This changes srvRoot to implement a custom FindMethod, though it does not actually have things registered and served via that method. (That is the next branch, because it is a mechanical change that involves a lot of lines of code.)

In my original (approved) version if this, I used a utils/registry.TypedNameVersion class for the Facades registry, rather than a bespoke Registry type. However, the only other use of that base class was in a test/example class, so I figured since I have to change it anyway, I'll just merge it into one well tested type-specific implementation.
I liked having the concept of a Registry in go, but having a specific implementation means we don't need to wrap it in type-specific helper functions. (The old one had to have proxy functions in common that just existed so that you could pass in a type-specific function, and get the exact type back out again.)

There is one mechanical change here, which is to change 'srvRoot' from having an 'srv' object into just having a direct 'state' attribute. We didn't actually need the srv attribute, and it just cluttered things up. Removing it makes it possible to have the TestingSrvRoot method that doesn't have to bring up an actual MongoDB just to test how the API holds things together.