# @ethronpi/zeromq

> A plugin to work with ZeroMQ in EthronLabs.

Latest version **0.1.0** (published 2020-07-19) · 0 weekly downloads

## Install

```sh
npm install @ethronpi/zeromq
pnpm add @ethronpi/zeromq
yarn add @ethronpi/zeromq
bun add @ethronpi/zeromq
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-07-19 |
| First published | 2020-07-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | EthronLabs |
| Maintainers | ethronpi |
| Keywords | ethron, plugin, zeromq |

## Links

- npm: https://www.npmjs.com/package/@ethronpi/zeromq
- npm.io page: https://npm.io/package/@ethronpi/zeromq

## Dependencies (1)

- [zeromq](https://npm.io/package/zeromq.md) ^6.0.0-beta.6

## Recent versions

- 0.1.0 (latest) — 2020-07-19

## README

# `@ethronpi/zeromq`

[![NPM version](https://img.shields.io/npm/v/@ethronpi/zeromq.svg)](https://npmjs.org/package/@ethronpi/zeromq)
[![Total downloads](https://img.shields.io/npm/dt/@ethronpi/zeromq.svg)](https://npmjs.org/package/@ethronpi/zeromq)

[Ethron](http://ethronlabs.com) plugin for [ZeroMQ](https://zeromq.org/).

*Developed in [Dogma](http://dogmalang.com), compiled to JavaScript.*

*Engineered in Valencia, Spain, EU by EthronLabs.*

## Use

```yaml
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.
  When `sever`, the socket is bound; if `client`, connected.

- `topic` (string), the topic to subscribe implicitly when `sub` 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](http://zeromq.github.io/zeromq.js/classes/context.html).

## Tasks

### send

It sends a single or multipart message on the socket.

```yaml
[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.

```yaml
[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 to `string` or `json`.

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.

```yaml
[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.

```yaml
[zeromq.unsubscribe]
[zeromq.unsubscribe, topic]
```

---
_Source: https://npm.io/package/@ethronpi/zeromq · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
