On Dec 21, 2009, at 6:36 PM, Luke Kanies <[email protected]> wrote:

> On Dec 21, 2009, at 6:16 PM, Luke Kanies wrote:
>
>> On Dec 21, 2009, at 5:45 PM, Bruce Williams wrote:
>>
>>> On Dec 21, 2009, at 5:25 PM, Luke Kanies <[email protected]> wrote:
>>>
>>>> Hi all,
>>>>
>>>> Anyone have any complaints if I rename the 'indirector' class to
>>>> 'router'?
>>>>
>>>> It's a much more appropriate and less frightening name.
>>>
>>> +1
>>
>> I'm actually doing this:
>>
>> s/Indirector/RouteManager/g
>> s/Indirection/Router/g
>> s/Terminus/Repository/g
>>
>> And looking into "fixing" the terminus/repository inheritance/ 
>> registration ridiculousness.
>>
>> I'll post it all for feedback.
>>
>> This is being driven by the need to dynamically configure routes  
>> (i.e., change which repository is used for a given routed class).   
>> I'd prefer to get all of these renames done first, esp. since I've  
>> been using 'Route' and 'Router' in my stub branch for this work,  
>> which is an ugly naming conflict.
>
> On the topic of the terminus/repository inheritance/registration  
> ridiculousness, I'll provide some extra context, and then explain  
> why I'm punting here.
>
> The current model is rigid in multiple ways.  Here's how it works  
> (using the new terminology):
>
> There is a base 'Repository' class, and all repository classes have  
> to inherit from it.  The ugly part is, everyone has to create what  
> amounts to an abstract subclass, and then each routed class needs  
> its own subclass, stored at router/$routed_class_name/ 
> $terminus_name.  For instance, we've got a RouteManager::Yaml class,  
> and Node has a subclass of it at route_manager/node/yaml.rb.
>
> Crucially, the constant associated with this class is  
> Puppet::Node::Yaml.  Note that the constant is outside the route  
> tree.  This, plus the repository inheritance, are required to  
> correctly associate a given repository class with a given routed  
> class.  We have to be able to map a given repository name and routed  
> class (e.g., the yaml repository for Node) to a file (so we know to  
> load route_manager/node/yaml.rb when we can't find the class) and  
> also to an actual class.
>
> This tuple to class is done by having each subclass of a subclass  
> (i.e., the node/yaml subclass of the yaml subclass of repository)  
> register itself with the routed class.  The human name is the last  
> bit of the constant -- 'yaml', in this case -- and the routed class  
> is the second to last bit of the constant -- node, in this case.   
> So, Repository gets its 'inherited' hook called, splits the  
> constant, finds the routed class by the second to last bit, and then  
> registers the class with it based on the last bit of the constant.
>
> It seems like there really must be a common idiom for this process  
> -- load classes on demand, and provide some simple mechanism to  
> automatically register those loaded classes with an appropriate  
> instance.

Using 'autoload' vs ActiveSupport's dependency mechanism + an  
'inherited' or 'included' hook would likely be my recommendation, long- 
term -- though I'd have to dig deeper to make sure.

>
> Because I don't actually have a better, simpler way to do this, and  
> because it's ugly but not hurtful, I'm punting on this and will just  
> build my routing support on top of these renames.
>
> -- 
> Never interrupt your enemy when he is making a mistake.
>    --Napolean Bonaparte
> ---------------------------------------------------------------------
> Luke Kanies  -|-   http://reductivelabs.com   -|-   +1(615)594-8199
>

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to