Skip to content

technoweenie/faraday-zeromq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Faraday-ZeroMQ

This is a simple ZeroMQ adapter for Faraday. It speaks a simple HTTP-like JSON protocol over a ZeroMQ REQ socket.

Protocol

Each request sends a header message, followed by a body message. The Header should be an object like this, serialized as JSON:

[method, path, headers]

After JSON serialization, it might look something like:

["get","/a",{"Content-Length":0}]

The body is not serialized in any way. Therefore, you can send any text or binary content.

The Response also comes in two messages. The header message is an object like this, serialized as JSON:

[status, headers]

After serialization, it looks like:

[200,{"Content-Type":"application/json"]

Like the request body, the response body has no serialization either.

USAGE

# if you want to use the rbzmq library, you may have to wrap it in a
# shim that responds to #send_string and #recv_string.
require 'ffi-rzmq'

context = ZMQ::Context.new
socket  = context.socket ZMQ::REQ
socket.connect 'tcp://127.0.0.1:5555'

conn = Faraday.new do |builder|
  builder.adapter :zeromq, socket
end

res = conn.get '/a'

See the examples directory for basic servers written in ruby, python, and node.js.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published