QWrapper is an attempt to make queue systems like SQS, AMQP, Redis consisten when advanced features aren't necessary. When simple dequeue, enqueue, poll, subscribe actions are the primary interfaces used then abstracting the logic can really DRY up code and simplyify usage.
This GEM is still in development phase. Please don't use this yet. I am still figuring out best use cases and proper conventions. Feel free to provide insight via issues.
Add this line to your application's Gemfile:
gem 'qwrapper'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install qwrapper
require "qwrapper"
Qwrapper.config = {
queue_type: :rabbitmq,
host: "localhost",
keepalive: true
}
Qwrapper.queue.publish("qwrapper", "test")
# OR
config = {
host: "localhost",
keepalive: true
}
queue = Qwrapper::Queues::RabbitMQ.new(config)
queue.publish("qwrapper", "test2")
require "qwrapper"
# Define custom classes for which to automatically
# requeue messages for.
class RetryError < StandardError; end
Qwrapper.config = {
queue_type: :rabbitmq,
host: "localhost",
keepalive: true
}
Qwrapper.queue.subscribe("qwrapper") do |message, logger|
# raise RetryError.new "Something temporary"
logger.debug "Doing some work...#{message}"
raise RetryError, "Some unexpected error occurred" if [true, false].sample
end
# OR
config = {
host: "localhost",
requeue_exceptions: [RetryError]
}
queue = Qwrapper::Queues::RabbitMQ.new(config)
queue.subscribe("qwrapper") do |message, logger|
# raise RetryError.new "Something temporary"
logger.debug "Doing some work...#{message}"
raise RetryError, "Some unexpected error occurred" if [true, false].sample
end
- Add requeue logic
- Add poison queue logic
- Improve logging. Make more intuitive w/o abusing it
- Think up more TODO items; there are plenty of concerns not listed here
TODO:
- Fork it ( https://github.com/[my-github-username]/qwrapper/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request