No time to wait http://showmetheco.de/index.rss Just code Twist 0.1 Mojolicious, Async::ORM and DBSlayer http://showmetheco.de/articles/2010/1/mojolicious-async-orm-and-dbslayer.html After experimenting with Redis in Mojo (http://github.com/vti/mojox-socket_stream) I wanted to do something asynchronously with DBI also, using my another Async::ORM module. But apparently doing async with DBI is not that easy. By itself DBI blocks everything and thus there are a few workarounds on CPAN with forks, sockets and pipes like AnyEvent::DBI, POE::Component::EasyDBI, POE::Component::SimpleDBI, IO::Lambda::DBI and others. That is why I have AnyEvent::DBI driver inside of Async::ORM. But I wanted to use Mojo::IOLoop as an event loop.

Writing another forking hack module is cool but I am not that smart, that's why I googled with a hope to find some event loop independent async DBI. And I found dbslayer (http://code.nytimes.com/projects/dbslayer/wiki). DBSlayer is a proxy between HTTP+JSON and MySQL. You send your SQL query as a GET request in JSON format and get JSON response. So what I needed is a http client that can send json requests and parse json responses. Mojo has got both.

See more code ]]>
Perl Mojolicious async orm dbslayer Sun, 31 Jan 2010 00:00:00 GMT http://showmetheco.de/articles/2010/1/mojolicious-async-orm-and-dbslayer.html