What's the best option for a Ruby desktop library library?

I am building a simple recipe search engine with Ruby and Sinatra for an iPhone application using RabbitMQ for my message queue. I look around and find many implementations for background processes, but most of them either implement their own message queuing algorithms or work like Rails plugins.

What's in there in terms of high quality frameworks-agnostic runtime libraries that will play well with RabbitMQ?

And are there any best practices I should keep in mind when writing working code, besides the obvious:

# BAD, don't do this!
begin
  # work
rescue Exception
end

      

0


a source to share


3 answers


I ended up writing my own library according to uncontrolled yak shaving. The Daemon kit was the right general idea, but seriously too heavy for my needs. I don’t want each of my daemons to look like a complete rails application. I will have at least 3 daemons and it will be a colossal mess of directories. The daemons gems have a terrible API, and while I was tempted to distract it, I realized it was probably easier to just manipulate the fork, so I did.

The API looks like this:

require "rubygems"
require "chaingang"

class Worker
  def setup
    # Set up connections here
  end

  def teardown
    # Tear down connections here
  end

  def call
    # Do some work
    sleep 1
  end
end
ChainGang.prepare(Worker.new)

      



And then you just use the included rake command to start / stop / restart or check the status. I took the page from the tutorial for the rack: anything that implements a method call

is fair play as an argument to the ChainGang.prepare and ChainGang.work methods, so Proc

is a valid work object.

It took me longer than I would need to use anything else, but I have a vague suspicion that it will pay off in the long run.

+1


a source


I am using Beanstalk and wrote my own daemons using the gem daemons . The daemon kit is a new project, but queue loops have not been implemented yet. You can also take a look at Nanite if it suits your needs, it is framework agnostic.



+1


a source


Check out nanites (written in Ruby), this is a young project written over rabbit.

github.com/ezmobius/nanite/tree/master

0


a source







All Articles