Skip to content
Eric Draut edited this page Oct 8, 2018 · 5 revisions

Detailed Configuration Example

case Rails.env
when 'development'
  ConeyIsland.config = {
    amqp_connection: {host: '127.0.0.1'},
    carousels: {
      default: { prefetch_count: 3 },
      cyclone: { prefetch_count: 3 },
      boardwalk: { prefetch_count: 1 }
    },
    log_level: 0,
    log: 'log/coney_island.log',
    notifier_service: 'Honeybadger'
  }
when 'staging','production'
  ConeyIsland.config = {
    amqp_connection_submitter: ENV['RABBITMQ_BIGWIG_TX_URL'],
    amqp_connection_worker: ENV['RABBITMQ_BIGWIG_RX_URL'],
    carousels: {
      default: { prefetch_count: 3, worker_count: 2 },
      cyclone: { prefetch_count: 3, worker_count: 2 },
      boardwalk: { prefetch_count: 1, worker_count: 2 }
    },
    log_level: 0,
    log: STDOUT,
    notifier_service: 'Honeybadger'
  }
end

AMQP Connection

The example back on the homepage shows an app that is connecting to RabbitMQ on the localhost. For RabbitMQ Bigwig on Heroku, you need to specify the publish and subscribe urls separately using amqp_connection_submitter and amqp_connection_worker as in the example above. If you use another RabbitMQ cloud service that has only a single url for both publishing and subscribing, use the amqp_connection option. The amqp_connection, amqp_connection_submitter, and amqp_connection_worker options all take either an amqp connection hash or a url string, as specified by the amqp gem in the connect method.

##Work Queues

The carousels option in the configuration lists work queues. In our example, default, cyclone, and boardwalk are work queues. You can create any arbitrary work queue name. We are fond of using cyclone for quick jobs and boardwalk for slow jobs as a cute Coney Island reference. The default queue is special, if you invoke a worker without specifying a queue name, it is automatically subscribed to the default queue.

Work Queue Options

prefetch_count

The number of jobs ConeyIsland will push to a worker without receiving an ack. If you have a queue where you really don't want jobs to be interleaved in the EventMachine reactor, set prefetch count to 1. That ensures that the worker only has one job at a time. If interleaving is OK and you have lots of short jobs, up the prefetch count to remove network latency between requests.

worker_count

The number of worker processes ConeyIsland will start when you invoke a worker. This is handy for environments like Heroku where you can't control multiple processes with God or Monit, and yet you want to take advantage of all the CPUs. The parent worker checks on children periodically and restarts if they've quit.

Logging

The log option takes either a file path or an IO object. It creates a ruby Logger using the provided file/IO info. You can set the log level for the Logger instance using the log_level option.

Notification Services

You can optionally send errors in job code to BugSnag, HoneyBadger, or Airbrake. Specify one of those names in the notifier_service option.

Clone this wiki locally