Skip to content

Commit

Permalink
Release 0.0.1
Browse files Browse the repository at this point in the history
Update README and project.clj
  • Loading branch information
gaverhae committed May 11, 2014
1 parent 73ce4c1 commit 08cb352
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 7 deletions.
96 changes: 91 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,103 @@
# naughtmq

NaughtMQ is a high-level wrapper around ZeroMQ for Clojure. It serves two distinct purposes:
NaughtMQ is a zero-config, zero-hassle way to use ZeroMQ wuth the JVM on the
three major platforms (Linux, OS X, Windows).

* Provide higher-level abstractions around ZeroMQ. Traditionally, ZeroMQ bindings remain fairly close to the C bindings. This is good, in that it allows programmer knowledge about ZeroMQ to be transferable accross languages, and it allows the one true [guide](http:https://zguide.zeromq.org) to serve as a unique, language-independent reference. However, in Clojure land, there is a case to be made for a more data-oriented API.
## Disclaimer

* Provide native libraries as part of the JAR. This is somewhat tricky, as the JAR format is not meant to carry native libraries (the JVM cannot, as far as I know, load native libraries directly from a ZIP file), in addition to the usual trust questions raised by the distribution of binary files. In this respect, this library may be seen (and used!) as just a way to embed the native libraries, as both [JZMQ](https://github.com/zeromq/jzmq) and [cljzmq](https://github.com/zeromq/cljzmq) are declared as dependencies, and therefore accessible.
As the version number suggest, this is a very early, alpha-level release.
Expect things to break. At the moment, I have been able to successfully run the
example programs below (in a `lein uberjar`) on OS X, Linux x86 and Linux
x86_64 (the same virtual machines as used for compiling, though on a clean
slate), and on Windows XP x86. I do not have access to a 64-bit version of
Windows.

## Usage

FIXME
### From Clojure

To include this library in a Leiningen-based project, add this line to your
dependencies:

```clojure
[naughtmq "0.0.1"]
```

Then, in your main namespace, require or use the `naughtmq.core` namespace **before** you import `org.zeromq.ZMQ`. As Clojure loads Java classes on import, you have to structure your `ns` declaration such that `naughtmq` comes first. Here is a minimal example of a Clojure namespace using `naughtmq`:

```clojure
(ns zmq-test.core
(:require [naughtmq.core :as nc])
(:import [org.zeromq ZMQ]))

(defn -main
[& args]
(println (ZMQ/getFullVersion)))
```

To allow for `org.zeromq.ZMQ` to be imported in the `ns` declaration, I have
set `naughtmq.core` to load the native libraries upon compilation. This means
that there is nothing else to do than `require`ing the namespace.

### From Java

The jar is on [clojars](https://clojars.org/), so you will have to add:

```xml
<repository>
<id>clojars.org</id>
<url>http:https://clojars.org/repo</url>
</repository>
```

to your `pom.xml`, in addition to the dependency to this library:

```xml
<dependency>
<groupId>naughtmq</groupId>
<artifactId>naughtmq</artifactId>
<version>0.0.1</version>
</dependency>
```

Java, in contrast with Clojure, does *not* actually load classes upon import.
The JVM actually waits for the first use of a classe to load it, which means
that the usage for `naughtmq` is quite natural. Here is a minimal example:

```java
package test.zmq.with.naught;

import org.zeromq.ZMQ; // order does not matter here
import naughtmq.Laoder;

public class Main {
public static void main(String[] args) {
Loader.load(); // order does matter here!
// this line must appear before any ZMQ call
System.out.println(ZMQ.getFullVersion()); // ZMQ is loaded here
// since the native libs have already been loaded by this point,
// everything works.
}
}
```

## How to build

If you want to build the binaries yourself (for example because you need a
different version of ZeroMQ), the process is, for the most part, easily
reproducible. To build the OS X binaries on OS X, just execute the Rakefile in
`resources/native/x86_64/mac`. To build the Linux binaries, any UNIX with
[Rake](http:https://rake.rubyforge.org/) and [Vagrant](http:https://www.vagrantup.com/)
will do (I have not made any extensive testing with other versions; I have used
Vagrant 1.5.4; I believe 1.5 is mandatory for the [new boxes
system](https://vagrantcloud.com/)).

On Windows, I have no idea how to automate things. The build process is [quite
straightforward](http:https://zeromq.org/bindings:java) if you have access to Visual
Studio.

## License

Copyright © 2013 Gary Verhaegen
Copyright © 2014 Gary Verhaegen

Distributed under the Eclipse Public License, the same as Clojure.
14 changes: 12 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
(defproject naughtmq "0.0.1-SNAPSHOT"
:description "A high-level Clojure wrapper for ZeroMQ"
(defproject naughtmq "0.0.1"
:description "A native-embedding wrapper for jzmq"
:url "https://github.com/gaverhae/naughtmq"
:scm {:name "git"
:url "https://github.com/gaverhae/naughtmq"}
:signing {:gpg-key "[email protected]"}
:deploy-repositories [["clojars" {:creds :gpg}]]
:pom-addition [:developers [:developer
[:name "Gary Verhaegen"]
[:url "https://github.com/gaverhae"]
[:email "[email protected]"]
[:timezone "+1"]]]
:license {:name "Eclipse Public License"
:url "http:https://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
Expand Down

0 comments on commit 08cb352

Please sign in to comment.