QueueIt

This is a gem for integrating Ruby on Rails with Queue-it that is an online queuing system, https://queue-it.com/

Installation

Add this line to your application's Gemfile:

gem 'queue_it'

And then execute:

$ bundle

Or install it yourself as:

$ gem install queue_it

Usage

We are using Queue-it on http://billetto.co.ok, and we create our queued events like this:

event  = create(:event,
                :queue_it_enabled               => true,
                :queue_it_customer_id           => 'billettodk',
                :queue_it_event_id              => 'rainmaking',
                :queue_it_known_user_secret_key => 'asdfbmnwqeklrj'
               )

In our Event-model, we determine whether or not its queue-enabled:

class Event < ActiveRecord::Base
  def queue_enabled?
    queue_it_enabled? &&
    queue_it_customer_id.present? &&
    queue_it_event_id.present? &&
    queue_it_known_user_secret_key.present?
  end
end

For us, our precious actions are all about tickets, so we protect these actions like this:

class EventsController < ApplicationController
  include QueueIt::Queueable

  def tickets
    event = Event.find(params[:id])

    if event.queue_enabled?
      protect_with_queue!(event.queue_it_known_user_secret_key,
                          event.queue_it_event_id,
                          event.queue_it_customer_id)
      # We use performed to see if our queue protection have rendered something,
      # if it has rendered stop all other execution
      return if performed?
    end
  end

  def receipt
    # The user has bought his/her tickets, push them out of the queue
    destroy_all_queue_it_sessions
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request