|
![]() |
Ruby/Event is Now DeadHi folks. After struggling with problems getting libevent to play fair with Ruby’s threading, I decided that it was too much effort for the gain and am dropping Ruby/Event. Feel free to take the code here and use it. You can contact me if you feel like maintaining it. People looking for the SCGI Rails Runner then go to it’s new project page for more information. Update: Sep 4 v. 0.4.2As mentioned on the index page this release fixed a couple little error reporting oversights for SCGI, and includes a complete scriptable telnet implementation that should be very correct. These instructions still mention 0.4.1 as I want to test 0.4.2 more and clean up the telnet implementation to make it an actual included Myriad library similar to SCGI. You can download the tar.bz2 or the rubygem if you want to test it. Update: Sep 1 v. 0.4.1The latest release is 0.4.1 which fixes a problem with SCGI exiting, and corrects documentation for running SCGI Rails under lighttpd. This release is also lightly tested with Apache. Ruby/Event and MyriadRuby/Event is a Ruby extension to the libevent library by Niels Provos to multiplex IO in the fastest way possible for your system. Ruby/Event tries to be as faithful to the libevent API while still looking like idiomatic Ruby so that both experienced libevent users and Ruby programmers can learn the API quickly. Finally, it completely wraps the library including the bufferevent structures, timeouts, and signals. In addition to this basic functionality Ruby/Event includes many examples and extensive RDoc documentation for your reference. I actually think the documentation for Ruby/Event is better documentation for libevent in general. I made sure that I read through the code to find out what functions did and documented any inconsistent behavior. You should hopefully be able to get started with Ruby/Event and probably even learn a little bit about libevent at the same time. Some people read “Ruby/Event” and think it’s for doing calendars even after reading that it uses libevent and handles buffers and all sorts of weird crap that has nothing to do with calendars.
Getting The GoodsYou can get:
There is a rough getting started guide coming soon, when I find more time. The Myriad FrameworkRuby/Event also includes a framework called Myriad that I’ve probably done in every language I know. The purpose of Myriad is to make it easier to work with TCP/IP events and data without killing your performance or having to learn yet another massive framework architecture. Myriad works kind of the way you probably already think about a protocol—as a series of expect/receive/send operations. Myriad does this by adding two more layers to the current TCP/IP protocol stack:
The Translation layer is already implemented and you usually don’t need to bother with it at all. The part you write is the Controller and your Application if you have a more complicated system. Many times you can mash the Control and Application layers together, but other times there is a clear separation between the two. I think this latest Ruby incarnation is the best as the features of Ruby really make it easy to implement protocol processors easily and quickly. Combined with Ruby/Event and Ruby I’ve managed to make Myriad a very nice clean library while still keeping the performance high compared to other Ruby frameworks. I really hope you’ll like it. Major Unfinished PartsWhile Myriad supports abstractions for reading messages, most events, timeouts, signals, and lots of grunt work, it is missing one big abstraction: writing messages. Currently I found it easier to just write a simple function to send the messages, but I would like to make the analog to the Reader for writing. Any ideas are welcome, but for now simply writing to the buffer seems to work great. Just keep in mind that this will change in the future, but your current use of writing will not be impacted. Another thing is that I’ve only used it for TCP/IP and not UDP or any other protocols. It probably would work but I just haven’t bothered. I don’t use UDP so let me know if you get it to work and have any suggestions. Don’t bother me though if you just want to tell me that I should only support UDP because it’s faster. Tell me it’s faster after you’ve implemented all the things TCP/IP provides you and then we’ll talk (after I demonstrate your UDP speed hitting 0 over a bad satellite link). Many Built-in ReadersMyriad includes a lot of the standard message formats that you find in many protocols these days, and makes it easy to create your own without having to modify the Myriad::Translator class to use them. The list of default supported formats are:
A Complete SCGI Implementation Supporting RailsThere is also a complete SCGI implementation included that is agnostic to the web framework, but implements a sample runner for Ruby On Rails suitable as an alternative to the FCGI system in use today. It will let you run a Rails application with a set of child processors, stop them, and get their status from one convenient command line utility. Simply check out the scgi_rails command with:
And you should be able to figure out the rest. There is also an example lighttpd.conf file that will run lighttpd against your SCGI children off a single port. Some folks claim to have problems with Apache’s SCGI implementation, so I’m looking into that. I’m also interested in writing a similar command for Og+Nitro and any other web frameworks out there. Hell I’m interested in writing a whole new web hosting framework to replace the complete aging WWW stack that all these frameworks are built on. I really think Myriad could do this well and clean up a lot of the cruft that is lying around. The SCGI implementation also supports the client side as well, which should help people test their SCGI servers and maybe even give them ideas for SCGI based systems. There’s more information in the Getting Started with SCGI guide. More InformationThe best place to check for complete installation information and getting started is the README that comes with the source distribution. Keep in mind that the project is licensed under the LGPL license so if you make modifications and distribute them then you should send them to me. Who the hell am I kidding, open source “users” are the absolute worst at giving back code they write. If you’re a good person you’ll give me back neat things you write, and I’ll of course give you credit. If you’re an evil bastard you’ll keep good stuff to yourself and pretend you’re an open source advocate. |