Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Swiss Army Knife of Network Concurrency, ZeroMQ, EventMachine, WebSockets, HTTP, and More

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc_img
Octocat-spinner-32 example
Octocat-spinner-32 js
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 dripdrop.gemspec


DripDrop is a library for structured message-passing async apps using EventMachine, ZeroMQ, and other protocols.

Here's an example of the kind of thing DripDrop makes easy, from example/combined.rb

require 'dripdrop'
Thread.abort_on_exception = true #Always a good idea in multithreaded apps.

# Encapsulates our EM and ZMQ reactors do
  # Define all our sockets
  route :stats_pub,      :zmq_publish,   'tcp://', :bind
  route :stats_sub1,     :zmq_subscribe, stats_pub.address, :connect
  route :stats_sub2,     :zmq_subscribe, stats_pub.address, :connect
  route :http_collector, :http_server,   ''
  route :http_agent,     :http_client,   http_collector.address

  stats_sub1.on_recv do |message|
    puts "Receiver 1: #{message.body}"
  stats_sub2.on_recv do |message|
    puts "Receiver 2: #{message.body}"

  i = 0
  http_collector.on_recv do |message,response|
    i += 1
    response.send_message(:name => 'ack', :body => {:seq => i})
  end do
    msg ='http/status', :body => "Success #{i}")
    http_agent.send_message(msg) do |resp_msg|
      puts "RESP: #{resp_msg.body['seq']}"
end.start! #Start the reactor and block until complete

Note that these aren't regular ZMQ sockets, and that the HTTP server isn't a regular server.They only speak and respond using DripDrop::Message formatted messages. For HTTP/WebSockets it's JSON that looks like {name: 'name', head: {}, body: anything}, for ZeroMQ it means MessagePack. There is a raw mode that you can use for other message formats, but using DripDrop::Messages makes things easier, and for some socket types (like XREQ/XREP) the predefined format is very useful in matching requests to replies.


RDocs can be found here. Most of the interesting stuff is in the Node and Message classes.

How It Works

DripDrop encapsulates both zmqmachine, and eventmachine. It provides some sane default messaging choices, using MessagePack(A binary, JSON, like serialization format) and JSON for serialization. While zmqmachine and eventmachine APIs, some convoluted ones, the goal here is to smooth over the bumps, and make them play together nicely.


Something went wrong with that request. Please try again.