Skip to content

azanar/baler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Dependency Status Coverage Status Code Climate Gem Version License Badges

Baler

Baler is a library for managing a pipelined task queue backed by RabbitMQ.

It is the amalgum of two other libraries:

Hopper manages binding to a RabbitMQ queue as a producer and/or consumer.

Hay manages making sense out of tasks and subsequent workflows, and is largely agnostic about how these get moved around.

Baler is the glue that makes RabbitMQ a producer/consumer for Hay style tasks.

Installation

Add this line to your application's Gemfile:

gem 'baler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install baler

Usage

A system using Baler does so by instantiating {Publisher}s and {Consumer}s.

Publisher

A Publisher accepts outbound messages and pass them along a Hay::Route, and are constructed on demand.

For example, imagine the following Route:

class MyRoute
  # A list of tasks that will have Consumers along this route
  def self.tasks
    [MyTask]
  end

  # Indicating this is a Route, which must happen *after* the task list
  # declaration.
  include Hay::Route
end

This is a declaration that MyRoute is the proper Route for messages to the Consumer of MyTask instances.

Detailed documentation on Route and Task classes can be found within the Hay project.

With this route, a {Publisher} can be instantiated as follows:

publisher = Baler::Publisher.new(MockRoute)

Messages can be sent to the Publisher instantiated above by calling Publisher#publish with a Hay::Message instance.

task = MyTask.new(params)

message = Hay::Message.new(my_task)

publisher.publish(message)

Consumers

Consumers accept inbound messages and act on them. Consumers are typically persistent daemons since messages could arrive on the associated queue at any time.

The following code sets up a Consumer for MyTask, and sets it listening on the expected queue.

class MyConsumer
  def tasks
    [MyTask]
  end

  include Hay::Consumer
end

consumer = Baler::Consumer.new(MyConsumer)
consumer.listen

API Documentation

See RubyDoc

Contributors

See Contributing for details.

Todo

See TODO for

License

©2014 Ed Carrel. Released under the MIT License.

See License for details.

About

A task management system leveraging Hay and Hopper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages