half-t / zmq_ex Goto Github PK
View Code? Open in Web Editor NEWElixir ZeroMQ implementation
Home Page: https://hex.pm/packages/zmq_ex
License: MIT License
Elixir ZeroMQ implementation
Home Page: https://hex.pm/packages/zmq_ex
License: MIT License
Elixir client should be able to connect to python server
Elixir server should allow connection from python client
https://github.com/half-t/zmq_ex/blob/master/lib/zmq_ex.ex#L42
GenServer
is a loop. If you recursively loop inside handle_*
, it can't process new messages ever.
E.g. The initiation in handle_info
should return state with socket and let GenServer accept new messages.
Later send_loop
can be replaced by handle_cast
like this.
# API function
send_message(pid, msg) when is_binary(msg) do
GenServer.cast(pid, {:send_msg, msg})
end
handle_cast({:send_msg, msg}, %{socket: socket}) do
enc_reply = encode(reply)
:gen_tcp.send(socket, enc_reply)
{:no_reply, state}
end
In general, never put loops inside handle_*
. Even when playing around :D
Move implementation details outside
As @tomekowal suggested #7 (comment) pre-commit hook can be created:
mix format --check-formatted
MIX_ENV=test mix do compile --warnings-as-errors
mix test
mix credo --strict
Hey guys! I want to participate a little bit, but I am not sure what is the end goal.
Could you explain what the project goal is?
How is it going to be different from existing work https://hex.pm/packages?_utf8=%E2%9C%93&search=zeromq&sort=recent_downloads
Is the project goal to learn or to make something production ready?
In case you'd like to make it production ready, I suggest using connection library for permanent connections https://hex.pm/packages/connection
And ranch as TCP acceptor pool https://hex.pm/packages/ranch
It would make both currently open PRs unnecessary.
(I am not that familiar with ZeroMQ so please check if that makes sense)
Compiling 1 file (.ex)
warning: variable "send?" is unused
lib/zmq_ex.ex:22
warning: variable "send?" is unused
lib/zmq_ex.ex:35
warning: function connect/2 is unused
lib/zmq_ex.ex:41
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.