Descriptionutils/registry: TypedNameVersion registry
As part of getting API versioning in place, I was putting together some
Registry's in a couple of places. I realized I wanted 2 things that were
essentially identical code, just tracking slightly different object
types. So I put together an abstraction that still enforces the Type,
but is otherwise treats the input and output as a generic interface{}.
I'm not stuck on the naming, though I went with
registry.TypedNameVersion as the handle for this thing. I could just as
easily calling simply registry.Registry and the fact that it enforces
Types and uses Name+Version as the key can just be in the docs.
I'm not 100% sure that we'll strictly need this, as the code is evolving
to where I may only have 1 registry. However, it still seemed like a
useful bit of functionality, and it was easily split out from the other
work as a self-contained and well tested bit of work.
If we prefer, I can wait to land this until it is clearly necessary
(rather than just having a single Registry that has a fixed object
type). But if we ever have >=2 registries with different types, I think
we'll want something like this.
https://code.launchpad.net/~jameinel/juju-core/typed-registry/+merge/219161
(do not edit description out of merge proposal)
Patch Set 1 #Patch Set 2 : utils/registry: TypedNameVersion registry #
Total comments: 6
MessagesTotal messages: 4
|