Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Add Travis CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Dinn committed Apr 10, 2014
1 parent ccf9ca4 commit 3d0b034
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
@@ -0,0 +1,7 @@
language: scala
scala:
- "2.10.3"
jdk:
- oraclejdk7
- openjdk7
- openjdk6
34 changes: 18 additions & 16 deletions README.md
@@ -1,20 +1,22 @@
# scala-zeromq

scala-zeromq facilitates communication using the [ZeroMQ](http://zeromq.org)
[![Build Status](https://travis-ci.org/mDialog/scala-zeromq.svg?branch=master)](https://travis-ci.org/mDialog/scala-zeromq)

scala-zeromq facilitates communication using the [ZeroMQ](http://zeromq.org)
messaging library. ZeroMQ is a message-oriented socket communication library that
supports several high-level messaging patterns, including request-reply,
publish-subscribe and push-pull. For a thorough description of how ZeroMQ works,
read the [guide](http://zguide.zeromq.org).
supports several high-level messaging patterns, including request-reply,
publish-subscribe and push-pull. For a thorough description of how ZeroMQ works,
read the [guide](http://zguide.zeromq.org).

Unlike many ZeroMQ libraries, scala-zeromq provides a *completely threadsafe*
ZeroMQ socket interface. All socket communications are conducted using an
immutable handle called a SocketRef. Under the hood, scala-zeromq uses
[Akka](http://akka.io) to ensure all socket interactions are handled safely and
efficiently.

**Requires libzmq (v2.1.0 or greater) and either
[JZMQ](https://github.com/zeromq/jzmq) or
[zeromq-scala-binding](https://github.com/valotrading/zeromq-scala-binding)**,
**Requires libzmq (v2.1.0 or greater) and either
[JZMQ](https://github.com/zeromq/jzmq) or
[zeromq-scala-binding](https://github.com/valotrading/zeromq-scala-binding)**,
neither is included automatically.

## Using
Expand All @@ -37,7 +39,7 @@ Then, bind one to a socket address and connect the other:

ZeroMQ supports several message transport protocols.

Next, send and receive a couple of messages. The `recv` method returns a Future
Next, send and receive a couple of messages. The `recv` method returns a Future
containing a message if one arrives before the timeout is reached.

pushSocket.send(Message(ByteString("one"), ByteString("two")))
Expand All @@ -51,7 +53,7 @@ containing a message if one arrives before the timeout is reached.
pullSocket.recv(10.seconds) map (println(_)) // returns Future, timeout 10s
// Message(ByteString("three"), ByteString("four")))

The `recvAll` method assigns a function to be called each time a message is
The `recvAll` method assigns a function to be called each time a message is
received by the socket.

pullSocket.recvAll { message: Message =>
Expand All @@ -68,7 +70,7 @@ if one is waiting to be received.
// Option[zeromq.Message] = Some(Message(ByteString("seven"), ByteString("eight")))

A scala-zeromq Message is a collection of
[akka.util.ByteString](http://doc.akka.io/api/akka/snapshot/#akka.util.ByteString)
[akka.util.ByteString](http://doc.akka.io/api/akka/snapshot/#akka.util.ByteString)
objects. Each item in the collection contains one ZeroMQ message part.

If you'd like to stop receiving messages on a socket, close it.
Expand All @@ -80,13 +82,13 @@ messages again you must create a new socket.

### Using with Akka

scala-zeromq is implemented as an
[Akka Extension](http://doc.akka.io/docs/akka/snapshot/scala/extending-akka.html).
To use it's fully asynchronous Akka interface, just load the extension.
scala-zeromq is implemented as an
[Akka Extension](http://doc.akka.io/docs/akka/snapshot/scala/extending-akka.html).
To use it's fully asynchronous Akka interface, just load the extension.

This branch uses Akka 2.3, the latest release version of Akka. If you're
using Akka 2.2, please use version 0.2.5. If you're using Akka 2.1 see the [0.1.X](https://github.com/mDialog/scala-zeromq/tree/0.1.X)
branch. If you're using Akka 2.0, see the [0.0.X](https://github.com/mDialog/scala-zeromq/tree/0.0.X)
branch. If you're using Akka 2.0, see the [0.0.X](https://github.com/mDialog/scala-zeromq/tree/0.0.X)
branch.

Use the extension to request a new socket. Assign an ActorRef as listener if you
Expand All @@ -97,7 +99,7 @@ expect the socket to receive messages.
val pushSocket = zmq.newSocket(SocketType.Push, Bind("tcp://localhost:5560"))
val pullSocket = zmq.newSocket(SocketType.Pull, Connect("tcp://localhost:5560"), Listener(anActorRef))

Each socket is a child of the actor responsible for creating it.
Each socket is a child of the actor responsible for creating it.

To send messages over the socket, send them to the socket actor.

Expand All @@ -106,7 +108,7 @@ To send messages over the socket, send them to the socket actor.
Messages are received as zeromq.Message objects sent to the actor assigned as
each socket's listener.

You can get and set options after socket creation by sending messages to the
You can get and set options after socket creation by sending messages to the
socket actor.

pushSocket ! Rate(100) // fire and forget
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Expand Up @@ -22,8 +22,8 @@ resolvers ++= Seq(
)

publishTo <<= version { (v: String) =>
if (v.trim.endsWith("-SNAPSHOT"))
if (v.trim.endsWith("-SNAPSHOT"))
Some(Resolver.file("Snapshots", file("../mdialog.github.com/snapshots/")))
else
Some(Resolver.file("Releases", file("../mdialog.github.com/releases/")))
}
}

0 comments on commit 3d0b034

Please sign in to comment.