Skip to content

Commit ba8fc15

Browse files
committed
Clojure core.async-based interface to ZeroMQ.
0 parents  commit ba8fc15

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

README.markdown

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ZeroMQ Async
2+
3+
ZeroMQ is a message-oriented socket system that supports many communication styles (request/response, publish/subscribe, fan-out, &c.) on top of many transport layers with bindings to many languages.
4+
This is a Clojure ZeroMQ interface built on core.async channels.
5+
6+
## Quick start
7+
8+
## Motivation
9+
10+
ZeroMQ sockets are not thread safe.
11+
To support concurrent usage from Clojure, you need to spin up a dedicated thread to read/write from a socket and expose the socket to the rest of your system via, e.g., `java.util.concurrent` queues.
12+
This library does that behind the scenes for you so you don't have to think about it.

project.clj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(defproject com.keminglabs/zmq-async "0.0.1-SNAPSHOT"
2+
:description "ZeroMQ 3 library for Clojure"
3+
:license {:name "BSD" :url "http://www.opensource.org/licenses/BSD-3-Clause"}
4+
5+
:min-lein-version "2.0.0"
6+
7+
:dependencies [[org.clojure/clojure "1.5.1"]
8+
[org.zeromq/jzmq "2.2.1-SNAPSHOT"]
9+
[core.async "0.1.0-SNAPSHOT"]]
10+
11+
:profiles {:dev {:source-paths ["dev"]
12+
:dependencies [[midje "1.5.1"]]}}
13+
14+
:jvm-opts ["-Djava.library.path=/usr/local/lib"])

src/zmq_async/core.clj

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(ns zmq-async.core
2+
(:import (org.zeromq ZMQ ZMQ$Socket)))
3+
4+
(def context
5+
(ZMQ/context 1))
6+
7+
(defn socket
8+
[socket-type]
9+
(.socket context (case socket-type
10+
:pull ZMQ/PULL
11+
:req ZMQ/REQ
12+
:rep ZMQ/REP
13+
:router ZMQ/ROUTER)))

0 commit comments

Comments
 (0)