Karait
A ridiculously simple queuing system, with clients in various languages, built on top of MongoDB.
Contributing to karait
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Usage
Writing to a queue
require 'karait'
queue = Karait::Queue.new(
:host => 'localhost', # MongoDB host. Defaults to localhost.
:port => 27017, # MongoDB port. Defaults to 27017.
:database => 'karait', # Database that will store the karait queue. Defaults to karait.
:queue => 'messages', # The capped collection that karait writes to. Defaults to messages.
:average_message_size => 8192, # How big do you expect the messages will be in bytes? Defaults to 8192.
:queue_size => 4096 # How many messages should be allowed in the queue. Defaults to 4096.
)
queue.write({
:name => 'Benjamin',
:action => 'Rock'
})
# or
= Karait::Message.new
.name = 'Benjamin'
.action = 'Rock!'
queue.write(, :routing_key => 'my_routing_key', :expire => 3.0)
Reading from a queue
require 'karait'
queue = Karait::Queue.new
= queue.read().first
print "#{.name}"
.delete
# or
= queue.read(:routing_key => 'my_routing_key').first
print "#{.action}"
.delete
See unit tests for more documentation.
Copyright
Copyright (c) 2011 Attachments.me. See LICENSE.txt for further details.