@ethronpi/zeromq
v0.1.0
Published
A plugin to work with ZeroMQ in EthronLabs.
Downloads
3
Readme
@ethronpi/zeromq
Developed in Dogma, compiled to JavaScript.
Engineered in Valencia, Spain, EU by EthronLabs.
Use
plugins:
- plugin: "@ethronpi/zeromq"
args:
socket: pair|push|pull|pub|sub|req
endpoint: endpoint
role: server|client
topic: topic
context: context
socket
(string, required), the socket type.endpoint
(string, required), the endpoint to connect or to bind.role
(string, required), the role to play. Whensever
, the socket is bound; ifclient
, connected.topic
(string), the topic to subscribe implicitly whensub
socket. If you need to subscribe to all the topics implicitly, set it empty text.context
(object), the context to use with the socket: Context class.
Tasks
send
It sends a single or multipart message on the socket.
[zeromq.send, message]
[zeromq.send, [my, message]]
[zeromq.send, [topic, message]]
Observations:
When pair socket used and no pair connected to the other end, the operation waits for its connection.
The sub sockets can't call this task, these are receive-only.
If req socket, it sends the message and waits for the response from the reply socket. On the other hand, if the reply socket is not available, it waits for its connection.
receive
It receives a single or multipart message on the socket.
[zeromq.receive]
[zeromq.receive, opts]
opts
(object), the receive options:timeout
(number), timeout in milliseconds.onTimeout
, message to return if timeout reached. If none set, error will be raised.encoding
(string), decode the message automatically: cast tostring
orjson
.
Observations:
- The req sockets have the implicit call to receive the response when a message sent. So well, you mustn't call this task with this type of socket.
subscribe
It subscribes to a given topic. When no topic set, all the messages received.
[zeromq.subscribe]
[zeromq.subscribe, topic]
When a sub
socket, we can set the topic as socket argument;
if not set there, we have to do it explicitly with this task.
unsubscribe
It unsubscribes from a topic or all the topics.
[zeromq.unsubscribe]
[zeromq.unsubscribe, topic]