Let's talk a little more about RPC, and YAML::RPC. A lot has changed in my mind in the past few days (slow bus journeys this week, meaning I have time to really mull things over).
YAML::RPC is cool, as I said before, but there are a couple of things about it that annoy me. One of them is that each handler must be registered in the server's config. This means you have one file with your actual handler sub definitions, and another with their names (or mapped names), and this tends to cause me to make mistakes.
The other problem with YAML::RPC is that it's, well, YAML, and whilst I love YAML for its simplicity, readability and syntactic brevity, it's also prone to nasty bugs. For example, YAML represents the undefined value with a tilda (
~), but in some circles this symbol can mean a user's home directory. If you don't take good care of your quoting, then in serializing and deserializing data you can turn a filesystem path into an undefined value. There are a few more examples involving the well-known whitespace issues, meaning that oftentimes you'll end up having to base64 encode data before serializing into YAML. This effort kind of undoes all the goodness brought about by YAML's syntax, don't you think?
So what I really want is an RPC system that avoids these two annoyances, and is a little more flexible than YAML::RPC in its dispatching mechanism, which is just a dumb call the sub thing. Okay, so I'll rewrite YAML::RPC to be Data::Serializer::RPC, and then we can use any data format, and get encryption/compression too if we want. I still need a flexible dispatcher and handler registration mechanism, and I want to have more options than just
ucspi-tcp or other
STDIN/STDOUT wrappers for network connectivity.
Seeing as the client-side of this will be a Catalyst model, it did strike me that Catalyst already has a lot of what I want... the flexible dispatcher, plugins (oh, yes, I was going to make it all pluggable using NEXT or Class:C3 because I like things like that), and network connectivity for free.
Hmm, why not just subvert Catalyst into an RPC system instead?
Around this time I happened to pop back onto
#catalyst to ask about their plugin system, and got chatting with the nice folks there, and explained my plans. Matt Trout, who is a fountain of ideas, piped up with "You should look at XMLRPC, or REST." No way was I going to touch XMLRPC; I get a rash every time I use XML. But this REST thing rang a bell, and so I went googling and reminded myself what it was all about.
Okay, so REST is basically just what the web is already doing, but as well as GET and POST for web pages, you use DELETE, PUT, etc (as with WebDAV) and call the things you get "resources". The body of the HTTP response, as we know from things like SOAP w/HTTP can be any old data. It could even be YAML! So rather than use YAML::RPC, which has its own calling syntax, use HTTP and GET a resource, or PUT one. The Wikipedia REST page does a reasonable job of explaining how REST methods can map to CRUD methods.
The final nail in the coffin for my YAML::RPC project was that some bright spark has already written the necessary frobnits to make Catalyst into a REST server, and they even use Data::Serializer in the transport. That's enough for the backend, so all I need to do is write a REST Model that acts as a client; this is simple and just uses standard Perl LWP. Hopefully that should sneak its way out to the CPAN before too long; I've just had a reply from my director giving open source release on the code, which I'm pleased about.
I've worked on three or four things over the last few days, most of which were nice to get out of the way, because it's what's on the horizon that I'm finding more interesting!
I pushed a new release of
Net::Appliance::Session and didn't hear much back about it, which was a little dissappointing to be honest. Earlier releases brought up five or six emails from around the world, with feature requests which were honoured in this release, so I'm anxious to hear what they think. I do now have a small group of users of the module though, which is more than I was ever expecting to know about, and I'm absolutely chuffed to bits with that.
Net::MAC module is shaping up to be something really cool. Earlier in the year I sent Karl, the author, a small patch bomb which he kindly incorporated, and over the weekend he got another which nukes two more items on his TODO list. I've not heard back, but fingers crossed they'll make the next release. I'd urge you to wait until 1.2 is released, as it's got tons more features than the version that's on CPAN right now. If you look at
Net::MAC is on its way to joining those two in my network hacker's Perl toolkit.
With those two things out of the way, my attention turns to
YAML::RPC. This is a complete module which is as-yet unreleased, and I'm hoping to get my employer's permission to do that before long. Another time, I'll talk about their open source policy, which is a very cool thing to have, IMO. Anyway,
YAML::RPC is also very cool, as it's a full RPC mechanism with a low overhead and human-readable (and writeable!) data stream. This makes testing a breeze! We hook it into something like
ucspi-tcp and immediately your MVC Model layer becomes a paper-thin RPC client and your business logic or DB work is nicely (and safely) abstracted away from your webserver.
Right now, however, I'm just reviewing my slides for tomorrow's session of the Introduction to Perl course that I teach for my employer. It's great fun, although massively stressful, because I've taken the course over from Stephen Quinney, and previously Simon Cozens, so there's a lot to live up to! I've made some heavy changes to the format though, and I think they're working out well. Perhaps more on this next week when the course is over.
Welcome, dear reader. Like many folks who keep an on-line journal, I eventally decided to split off my geeky alter-ego from the traditional blog. So now I have this page here, for all that's techy in my life, and another page with stories about cats, gardening, friends, and SWMBO.
Let me introduce myself. My job title is "Senior Network Development and Support Officer", and I work for the University of Oxford. In plain English, it means that I co-admin a lot of Cisco kit, some DNS/DHCP/SMTP/RADIUS/etc servers, and write a ton of Perl, along with my colleagues Robin and Andy. I guess my two geeky loves are IP networks, and Perl
As we all know, it's Perl that glues the Cisco/DNS/etc bits together, and that's what I want to write about here. I hope the things I do will prove interesting, and from time to time I'll throw in something from home (MythTV being an example).