Coder Social home page Coder Social logo

exzmq's Introduction

exzmq - ØMQ in pure Elixir

exzmq implements the ØMQ protocol in 100% pure Elixir.

Base on the original work from ezmq(https://github.com/zeromq/ezmq)

Motivation

ØMQ is like Erlang message passing for the rest of the world without the overhead of a C-Node. So using it to talk to rest of the World seems like a good idea. Several Erlang wrappers for the C++ reference implemention do exist. So why reinvent the wheel in Elixir?

Elixir is the way forward for the beam community, it feel like the good time to have an implementation of zeromq.

Secondly, when using the C++ implementation we encountered several segfault taking down the entire Erlang VM and most importantly, the whole concept is so erlangish, that it feels like it has to be implemented in Elixir itself.

Main features

  • ØMQ compatible : ZMTP 1.0 (http://rfc.zeromq.org/spec:13)
  • 100% Elixir
  • good fault isolation (a crash in the message decoder won't take down your Erlang VM)
  • API very similar to other socket interfaces
  • runs on non SMP and SMP VM

Examples

defmodule Exzmq.Examples.HWserver do

  def main() do
    {:ok, socket} = Exzmq.start([{:type, :rep}])
    Exzmq.bind(socket, :tcp, 5555, [])
    loop(socket)
  end
  
  defp loop(socket) do
    Exzmq.recv(socket)
    :io.format("Received Hello~n")
    Exzmq.send(socket, [<<"World">>])
    loop(socket)
  end
end


defmodule Exzmq.Examples.HWclient do

  def main() do
    {:ok, socket} = Exzmq.start([{:type, :req}])
    Exzmq.connect(socket, :tcp, {127,0,0,1}, 5555, [])
    loop(socket, 0)
  end

  defp loop(_socket, 10), do: :ok

  defp loop(socket, n) do
	 :io.format("Sending Hello ~w ...~n",[n])
	 Exzmq.send(socket, [<<"Hello",0>>])
	 {:ok, r} = Exzmq.recv(socket)
     :io.format("Received '~s' ~w~n", [r, n])
	 loop(socket, n+1)
  end
end	

Contribution process

TODO:

  • ZMTP 2.0
  • documentation
  • push/pull sockets
  • identity support
  • send queue improvements
  • high water marks for send queue

License

The project is released under the MPL 2.0 license http://mozilla.org/MPL/2.0/.

exzmq's People

Contributors

plemanach avatar benjamintanweihao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.