A week or so back we started porting projects to Rails 3 and all new projects were created using Rails 3. The project that I was working on (name irrelevant) needed some sort of concurrency. In the past we already tried a few existing Gems but there was always something missing or there was simply too much of something. Is most cases it was also hard to customize the gem or it simply didn’t live up to our expectations.
In the past we had also tried to create our own concurrency implementation but these either-way failed or were just too specifically designed. If you wanted to do something else than the feature it was designed for; you would have to rewrite parts of the code. You may call this design error, but it was simply not the intention to create a flexible concurrency implementation.
So our search for a new concurrency Gem went on; we tried two and came to the conclusion we would have to write something our self. I was given the task to create a new Gem. A new concurrency (queueing) Gem which would have to be flexible, maintainable and would have to be not as specific as we have been in the past. Or in fact this concurrency Gem had to be able to do all sort of tasks. From sending out mails to importing users from a CSV file.
I’d tried delayed_jobs and liked their implementation very much. The one thing we all agreed at here at the office was we didn’t want to have a separate Rake task which would require to be run in order to do some sort of concurrency. We wanted to be able to have the task been done within the application with whatever concurrency we specified; be it Forking or Threading or a simple yield, it all had to be possible. So with delayed_job in mind I started to design the Gem and came up with the name Runner (obvious name!).
I took me two days to implement a very basic version of the Gem. The only thing it could do back then was fork a method in the background without the need of an additional Rake task. At the current time of writing it has the following features:
- Supports various implementations of Concurrency (forking, threading and yielding. But the last isn’t really concurrency)
- Developers using the Gem may add different kind of concurrency to gem by simply giving the concurrency class the Runner initializer
- It has the ability to queue tasks which means you more or less park the tasks for later.
- It may immediately run tasks in the background using the various concurrency methods.
- Threading tasks requires no changes to your current classes.
- Extending the backend (currently comes with ActiveRecord) only requires you to implement database specific code (scopes, etc.)
Yoki Sonoda has just announced the stable release of Ruby 1.9.2!
== About Ruby 1.9.2
Ruby 1.9.2 is mostly compatible with 1.9.1, except the
* Many new methods
* New socket API (IPv6 support)
* New encodings
* Random class that supports various random number generators
* Time is reimplemented. There is no longer the year 2038 problem.
* some regexp enhancements
* $: no longer includes the current directory.
* dl is reimplemented on top of libffi.
* new psych library that wraps libyaml. You can use the library instead
It has been verified that 1.9.2 works on; Windows (32 and 64 bit version as well as mingw 32), FreeBSD 6, MacOSX 10.5 (intel and 10.6, Solaris 10 and Symbian OS.
Let’s hope Rails 3 will get released this week too! :)
A couple of days back I was looking over my Blog Stats and an interesting search query came up:
objectiveresource does it need rails?
This query got me interested in trying out Objective resource without rails, and technically it should be possible because ObjectiveResource just requires the fetched XML to be in a specific format. So what we can do is create a simple XML document in the same format as Rails out puts its XML. And while we’re at it, let’s create a simple webserver which outputs the XML (honestly I just don’t have Apache working here on my laptop and I seriously can’t be arsed to set it up, and its way too much fun to create a simple Ruby webserver.). So let’s get started!
So you want to try ruby 1.9 and rails 3? Awesome! You’ve come to the right place. Before installing ruby 1.9 or rails 3 you want to install RVM (Ruby Version Manager). RVM is a handy tool which allows you to have multiple version of Ruby installed on your system (along with gems, which include Rails).
RVM — Ruby Version Manager
Straight from the RVM Website:
RVM is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems. RVM itself is easy to install!
I couldn’t have explained it better my self. So let’s get started! In order to install RVM just download the gem
sudo gem install rvm
I haven’t written anything for quite a while, mostly because I simply had nothing interesting to write about. Or at least nothing interesting about Cocoa or Objective-C. The last couple of weeks I’ve been doing less than the usual amount of Objective-C and/or Cocoa. One of the reasons is work and partly because I’ve been lazy. With lazy I’m not saying I haven’t done any programming or reading about programming languages at all. Work has forced me in doing more Ruby/Ruby on Rails simply because the projects I’m on had higher priority than the iPhone apps. And to be fairly honest; I didn’t mind at all.