HLL Configuration Directives
Submitted by jeff on July 12, 2008 - 11:31am.For the first time in a long while I have copious amounts of free time over the weekend. So I decided to look at what I had long considered the most difficult part of mod_parrot: HLL configuration directives. Turns out they're not so hard after all.
What is an HLL configuration directive? Well, consider what you have to do now to declare a Perl 6 response handler (in httpd.conf):
<Location /foo> SetHandler parrot-code ParrotLanguage perl6 ParrotHandler My::Handler </Location>
These directives violate one of the goals of mod_parrot: stay invisible. But with HLL configuration directives, we could have something like this:
<Location /foo> SetHandler perl6-code Perl6ResponseHandler My::Handler </Location>
This makes configuration much simpler, more familiar to current mod_perl developers, and completely hides mod_parrot from view.
One Apache module implements this functionality, and that's mod_perl2, where you can add custom Apache directives from your modules. I did a lot of research on how this is accomplished, and it's actually quite simple:
- Write a thunking layer for the various configuration signatures to pass configuration info from Apache to the HLL
- Create a new Apache module dynamically at runtime
- Create a
command_recstructure containing your directives and pointers to the thunking layer - Associate the
command_recwith the new module - Register the module with Apache
Of course the actual implementation is the difficult part, but today I was able to write a simple proof-of-concept. It creates a new module at runtime and adds a directive that writes to the error log when it's encountered in the configuration. Hard part done!
What's next? I have to refactor everything I've done to make it extensible and callable from Parrot. Then I can write the PIR interface for HLLs to add their directives. And if I'm careful about the design, modules like mod_perl6 will be able to reuse the interface to add directives for their own handlers, like mod_perl2 does today. My goal is to have this in a usable state by OSCON. My fingers are crossed!
