node-red-contrib-qrusty 0.19.19 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/qrusty-nack.js CHANGED
@@ -1,12 +1,32 @@
1
- // Function node for negative-acknowledging a message in qrusty
2
- msg.url =
3
- "http://queue-server:6784/nack/" +
4
- (msg.queue || "default_queue") +
5
- "/" +
6
- msg.messageId;
7
- msg.method = "POST";
8
- msg.payload = {
9
- consumer_id: msg.consumer_id || "node-red-consumer",
1
+ // qrusty-nack.js
2
+ //
3
+ // Negatively acknowledges a previously-consumed message. msg.payload
4
+ // becomes `true` on success or `false` if the server returned 404.
5
+
6
+ const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
7
+
8
+ module.exports = function (RED) {
9
+ function QrustyNackNode(n) {
10
+ RED.nodes.createNode(this, n);
11
+ const node = this;
12
+ const server = RED.nodes.getNode(n.server);
13
+
14
+ setupActionNode(node, server, async (client, msg) => {
15
+ const queue = fromConfigOrMsg(n.queue, msg.queue);
16
+ if (!queue) throw new Error("queue is required");
17
+ const messageId = fromConfigOrMsg(
18
+ undefined,
19
+ msg.messageId ?? msg.id ?? msg.message_id,
20
+ );
21
+ if (!messageId) {
22
+ throw new Error("messageId is required (set msg.messageId or msg.id)");
23
+ }
24
+ const consumerId =
25
+ fromConfigOrMsg(n.consumerId, msg.consumer_id) || "node-red-consumer";
26
+
27
+ return await client.nack(queue, messageId, consumerId);
28
+ });
29
+ }
30
+
31
+ RED.nodes.registerType("qrusty-nack", QrustyNackNode);
10
32
  };
11
- msg.headers = { "Content-Type": "application/json" };
12
- return msg;
@@ -0,0 +1,92 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-publish", {
3
+ category: "qrusty",
4
+ color: "#d78a4e",
5
+ defaults: {
6
+ name: { value: "" },
7
+ server: { value: "", type: "qrusty-server", required: true },
8
+ queue: { value: "" },
9
+ priority: { value: "" },
10
+ maxRetries: { value: "" },
11
+ },
12
+ inputs: 1,
13
+ outputs: 1,
14
+ icon: "font-awesome/fa-paper-plane",
15
+ label: function () {
16
+ return this.name || "qrusty publish";
17
+ },
18
+ paletteLabel: "publish",
19
+ });
20
+ </script>
21
+
22
+ <script type="text/html" data-template-name="qrusty-publish">
23
+ <div class="form-row">
24
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
25
+ <input type="text" id="node-input-name" placeholder="optional" />
26
+ </div>
27
+ <div class="form-row">
28
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
29
+ <input type="text" id="node-input-server" />
30
+ </div>
31
+ <div class="form-row">
32
+ <label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
33
+ <input
34
+ type="text"
35
+ id="node-input-queue"
36
+ placeholder="leave blank to use msg.queue"
37
+ />
38
+ </div>
39
+ <div class="form-row">
40
+ <label for="node-input-priority"
41
+ ><i class="fa fa-sort-numeric-desc"></i> Priority</label
42
+ >
43
+ <input
44
+ type="number"
45
+ id="node-input-priority"
46
+ placeholder="default 0 or msg.priority"
47
+ />
48
+ </div>
49
+ <div class="form-row">
50
+ <label for="node-input-maxRetries"
51
+ ><i class="fa fa-refresh"></i> Max retries</label
52
+ >
53
+ <input
54
+ type="number"
55
+ id="node-input-maxRetries"
56
+ placeholder="default 3 or msg.max_retries"
57
+ />
58
+ </div>
59
+ </script>
60
+
61
+ <script type="text/html" data-help-name="qrusty-publish">
62
+ <p>Publishes <code>msg.payload</code> to a Qrusty queue.</p>
63
+ <h3>Inputs</h3>
64
+ <dl class="message-properties">
65
+ <dt>payload <span class="property-type">any</span></dt>
66
+ <dd>
67
+ The message body. Non-string payloads are automatically
68
+ JSON-stringified by the client.
69
+ </dd>
70
+ <dt class="optional">queue <span class="property-type">string</span></dt>
71
+ <dd>
72
+ Target queue name. Used when the node's <b>Queue</b> field is blank.
73
+ </dd>
74
+ <dt class="optional">priority <span class="property-type">number</span></dt>
75
+ <dd>
76
+ Message priority. Used when the node's <b>Priority</b> field is blank.
77
+ </dd>
78
+ <dt class="optional">max_retries <span class="property-type">number</span></dt>
79
+ <dd>
80
+ Retry ceiling before the message moves to the DLQ. Used when the
81
+ node's <b>Max retries</b> field is blank.
82
+ </dd>
83
+ </dl>
84
+ <h3>Outputs</h3>
85
+ <dl class="message-properties">
86
+ <dt>payload <span class="property-type">object</span></dt>
87
+ <dd>
88
+ The server response: <code>{ id: "&lt;uuid&gt;" }</code> for the
89
+ newly-published message.
90
+ </dd>
91
+ </dl>
92
+ </script>
package/qrusty-publish.js CHANGED
@@ -1,11 +1,38 @@
1
- // Function node for publishing to qrusty
2
- msg.url = "http://queue-server:6784/publish";
3
- msg.method = "POST";
4
- msg.payload = {
5
- queue: "my_queue",
6
- priority: msg.priority || 1000,
7
- payload: JSON.stringify(msg.payload),
8
- max_retries: 3,
1
+ // qrusty-publish.js
2
+ //
3
+ // Publishes `msg.payload` to a Qrusty queue.
4
+ //
5
+ // The queue, priority, and max_retries can be set in the node config
6
+ // (takes precedence) or via `msg.queue` / `msg.priority` / `msg.max_retries`.
7
+ // The resulting message id from the server is written back to
8
+ // `msg.payload = { id: "..." }`.
9
+
10
+ const {
11
+ setupActionNode,
12
+ fromConfigOrMsg,
13
+ toNumberOrUndefined,
14
+ } = require("./lib/common");
15
+
16
+ module.exports = function (RED) {
17
+ function QrustyPublishNode(n) {
18
+ RED.nodes.createNode(this, n);
19
+ const node = this;
20
+ const server = RED.nodes.getNode(n.server);
21
+
22
+ setupActionNode(node, server, async (client, msg) => {
23
+ const queue = fromConfigOrMsg(n.queue, msg.queue);
24
+ if (!queue) {
25
+ throw new Error("queue is required (set on the node or via msg.queue)");
26
+ }
27
+ const priority =
28
+ toNumberOrUndefined(fromConfigOrMsg(n.priority, msg.priority)) ?? 0;
29
+ const maxRetries =
30
+ toNumberOrUndefined(fromConfigOrMsg(n.maxRetries, msg.max_retries)) ??
31
+ 3;
32
+
33
+ return await client.publish(queue, priority, msg.payload, maxRetries);
34
+ });
35
+ }
36
+
37
+ RED.nodes.registerType("qrusty-publish", QrustyPublishNode);
9
38
  };
10
- msg.headers = { "Content-Type": "application/json" };
11
- return msg;
@@ -0,0 +1,41 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-purge-all", {
3
+ category: "qrusty",
4
+ color: "#e99999",
5
+ defaults: {
6
+ name: { value: "" },
7
+ server: { value: "", type: "qrusty-server", required: true },
8
+ },
9
+ inputs: 1,
10
+ outputs: 1,
11
+ icon: "font-awesome/fa-eraser",
12
+ label: function () {
13
+ return this.name || "qrusty purge-all";
14
+ },
15
+ paletteLabel: "purge-all",
16
+ });
17
+ </script>
18
+
19
+ <script type="text/html" data-template-name="qrusty-purge-all">
20
+ <div class="form-row">
21
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
+ <input type="text" id="node-input-name" placeholder="optional" />
23
+ </div>
24
+ <div class="form-row">
25
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
26
+ <input type="text" id="node-input-server" />
27
+ </div>
28
+ </script>
29
+
30
+ <script type="text/html" data-help-name="qrusty-purge-all">
31
+ <p>Purges every message from every queue on the server.</p>
32
+ <p>
33
+ The queues themselves are not deleted &mdash; use
34
+ <code>qrusty-delete-all</code> for that.
35
+ </p>
36
+ <h3>Outputs</h3>
37
+ <dl class="message-properties">
38
+ <dt>payload <span class="property-type">object</span></dt>
39
+ <dd>Server response.</dd>
40
+ </dl>
41
+ </script>
@@ -1,5 +1,19 @@
1
- // Function node for purging all messages from all queues in qrusty
2
- msg.url = "http://queue-server:6784/purge-all";
3
- msg.method = "POST";
4
- msg.headers = { "Content-Type": "application/json" };
5
- return msg;
1
+ // qrusty-purge-all.js
2
+ //
3
+ // Purges every queue on the server (but leaves them in place).
4
+
5
+ const { setupActionNode } = require("./lib/common");
6
+
7
+ module.exports = function (RED) {
8
+ function QrustyPurgeAllNode(n) {
9
+ RED.nodes.createNode(this, n);
10
+ const node = this;
11
+ const server = RED.nodes.getNode(n.server);
12
+
13
+ setupActionNode(node, server, async (client /*, msg */) => {
14
+ return await client.purgeAll();
15
+ });
16
+ }
17
+
18
+ RED.nodes.registerType("qrusty-purge-all", QrustyPurgeAllNode);
19
+ };
@@ -0,0 +1,51 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-purge-queue", {
3
+ category: "qrusty",
4
+ color: "#e99999",
5
+ defaults: {
6
+ name: { value: "" },
7
+ server: { value: "", type: "qrusty-server", required: true },
8
+ queue: { value: "" },
9
+ },
10
+ inputs: 1,
11
+ outputs: 1,
12
+ icon: "font-awesome/fa-eraser",
13
+ label: function () {
14
+ return this.name || "qrusty purge-queue";
15
+ },
16
+ paletteLabel: "purge-queue",
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="qrusty-purge-queue">
21
+ <div class="form-row">
22
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-input-name" placeholder="optional" />
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
27
+ <input type="text" id="node-input-server" />
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
31
+ <input
32
+ type="text"
33
+ id="node-input-queue"
34
+ placeholder="leave blank to use msg.queue"
35
+ />
36
+ </div>
37
+ </script>
38
+
39
+ <script type="text/html" data-help-name="qrusty-purge-queue">
40
+ <p>Removes every message from a queue, leaving the queue itself in place.</p>
41
+ <h3>Inputs</h3>
42
+ <dl class="message-properties">
43
+ <dt class="optional">queue <span class="property-type">string</span></dt>
44
+ <dd>Queue to purge (when the Queue field is blank).</dd>
45
+ </dl>
46
+ <h3>Outputs</h3>
47
+ <dl class="message-properties">
48
+ <dt>payload <span class="property-type">object</span></dt>
49
+ <dd>Server response.</dd>
50
+ </dl>
51
+ </script>
@@ -1,5 +1,21 @@
1
- // Function node for purging all messages from a queue in qrusty
2
- msg.url = "http://queue-server:6784/purge-queue/" + (msg.queue || "my_queue");
3
- msg.method = "POST";
4
- msg.headers = { "Content-Type": "application/json" };
5
- return msg;
1
+ // qrusty-purge-queue.js
2
+ //
3
+ // Removes all messages from a queue without deleting the queue itself.
4
+
5
+ const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
6
+
7
+ module.exports = function (RED) {
8
+ function QrustyPurgeQueueNode(n) {
9
+ RED.nodes.createNode(this, n);
10
+ const node = this;
11
+ const server = RED.nodes.getNode(n.server);
12
+
13
+ setupActionNode(node, server, async (client, msg) => {
14
+ const queue = fromConfigOrMsg(n.queue, msg.queue);
15
+ if (!queue) throw new Error("queue name is required");
16
+ return await client.purge(queue);
17
+ });
18
+ }
19
+
20
+ RED.nodes.registerType("qrusty-purge-queue", QrustyPurgeQueueNode);
21
+ };
@@ -0,0 +1,51 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-queue-metrics", {
3
+ category: "qrusty",
4
+ color: "#b9d18c",
5
+ defaults: {
6
+ name: { value: "" },
7
+ server: { value: "", type: "qrusty-server", required: true },
8
+ queue: { value: "" },
9
+ },
10
+ inputs: 1,
11
+ outputs: 1,
12
+ icon: "font-awesome/fa-line-chart",
13
+ label: function () {
14
+ return this.name || "qrusty queue-metrics";
15
+ },
16
+ paletteLabel: "queue-metrics",
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="qrusty-queue-metrics">
21
+ <div class="form-row">
22
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-input-name" placeholder="optional" />
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
27
+ <input type="text" id="node-input-server" />
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
31
+ <input
32
+ type="text"
33
+ id="node-input-queue"
34
+ placeholder="leave blank to use msg.queue"
35
+ />
36
+ </div>
37
+ </script>
38
+
39
+ <script type="text/html" data-help-name="qrusty-queue-metrics">
40
+ <p>Fetches time-series metrics (per-second buckets) for a queue.</p>
41
+ <h3>Inputs</h3>
42
+ <dl class="message-properties">
43
+ <dt class="optional">queue <span class="property-type">string</span></dt>
44
+ <dd>Queue to inspect.</dd>
45
+ </dl>
46
+ <h3>Outputs</h3>
47
+ <dl class="message-properties">
48
+ <dt>payload <span class="property-type">object</span></dt>
49
+ <dd>The time-series metrics payload (pub/ack/nack counts per second).</dd>
50
+ </dl>
51
+ </script>
@@ -1,6 +1,21 @@
1
- // Function node for getting time-series metrics for a queue in qrusty
2
- msg.url =
3
- "http://queue-server:6784/queues/" + (msg.queue || "my_queue") + "/metrics";
4
- msg.method = "GET";
5
- msg.headers = { "Content-Type": "application/json" };
6
- return msg;
1
+ // qrusty-queue-metrics.js
2
+ //
3
+ // Fetches time-series metrics (per-second buckets) for a queue.
4
+
5
+ const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
6
+
7
+ module.exports = function (RED) {
8
+ function QrustyQueueMetricsNode(n) {
9
+ RED.nodes.createNode(this, n);
10
+ const node = this;
11
+ const server = RED.nodes.getNode(n.server);
12
+
13
+ setupActionNode(node, server, async (client, msg) => {
14
+ const queue = fromConfigOrMsg(n.queue, msg.queue);
15
+ if (!queue) throw new Error("queue is required");
16
+ return await client.queueMetrics(queue);
17
+ });
18
+ }
19
+
20
+ RED.nodes.registerType("qrusty-queue-metrics", QrustyQueueMetricsNode);
21
+ };
@@ -0,0 +1,51 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-queue-stats", {
3
+ category: "qrusty",
4
+ color: "#b9d18c",
5
+ defaults: {
6
+ name: { value: "" },
7
+ server: { value: "", type: "qrusty-server", required: true },
8
+ queue: { value: "" },
9
+ },
10
+ inputs: 1,
11
+ outputs: 1,
12
+ icon: "font-awesome/fa-bar-chart",
13
+ label: function () {
14
+ return this.name || "qrusty queue-stats";
15
+ },
16
+ paletteLabel: "queue-stats",
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="qrusty-queue-stats">
21
+ <div class="form-row">
22
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-input-name" placeholder="optional" />
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
27
+ <input type="text" id="node-input-server" />
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-input-queue"><i class="fa fa-list"></i> Queue</label>
31
+ <input
32
+ type="text"
33
+ id="node-input-queue"
34
+ placeholder="leave blank to use msg.queue"
35
+ />
36
+ </div>
37
+ </script>
38
+
39
+ <script type="text/html" data-help-name="qrusty-queue-stats">
40
+ <p>Fetches detailed statistics for a single queue.</p>
41
+ <h3>Inputs</h3>
42
+ <dl class="message-properties">
43
+ <dt class="optional">queue <span class="property-type">string</span></dt>
44
+ <dd>Queue to inspect.</dd>
45
+ </dl>
46
+ <h3>Outputs</h3>
47
+ <dl class="message-properties">
48
+ <dt>payload <span class="property-type">object</span></dt>
49
+ <dd>The per-queue stats object (counts, rates, config).</dd>
50
+ </dl>
51
+ </script>
@@ -1,5 +1,21 @@
1
- // Function node for getting stats for a specific queue in qrusty
2
- msg.url = "http://queue-server:6784/queue-stats/" + (msg.queue || "my_queue");
3
- msg.method = "GET";
4
- msg.headers = { "Content-Type": "application/json" };
5
- return msg;
1
+ // qrusty-queue-stats.js
2
+ //
3
+ // Fetches detailed stats for one specific queue.
4
+
5
+ const { setupActionNode, fromConfigOrMsg } = require("./lib/common");
6
+
7
+ module.exports = function (RED) {
8
+ function QrustyQueueStatsNode(n) {
9
+ RED.nodes.createNode(this, n);
10
+ const node = this;
11
+ const server = RED.nodes.getNode(n.server);
12
+
13
+ setupActionNode(node, server, async (client, msg) => {
14
+ const queue = fromConfigOrMsg(n.queue, msg.queue);
15
+ if (!queue) throw new Error("queue is required");
16
+ return await client.queueStats(queue);
17
+ });
18
+ }
19
+
20
+ RED.nodes.registerType("qrusty-queue-stats", QrustyQueueStatsNode);
21
+ };
@@ -0,0 +1,64 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-server", {
3
+ category: "config",
4
+ defaults: {
5
+ name: { value: "" },
6
+ host: { value: "localhost", required: true },
7
+ port: {
8
+ value: 6784,
9
+ required: true,
10
+ validate: RED.validators.number(),
11
+ },
12
+ useHttps: { value: false },
13
+ },
14
+ label: function () {
15
+ return this.name || this.host + ":" + this.port;
16
+ },
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="qrusty-server">
21
+ <div class="form-row">
22
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-config-input-name" placeholder="optional" />
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-config-input-host"><i class="fa fa-server"></i> Host</label>
27
+ <input type="text" id="node-config-input-host" placeholder="localhost" />
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-config-input-port"><i class="fa fa-sign-in"></i> Port</label>
31
+ <input type="number" id="node-config-input-port" placeholder="6784" />
32
+ </div>
33
+ <div class="form-row">
34
+ <label for="node-config-input-useHttps"><i class="fa fa-lock"></i> HTTPS</label>
35
+ <input
36
+ type="checkbox"
37
+ id="node-config-input-useHttps"
38
+ style="display: inline-block; width: auto; vertical-align: top;"
39
+ />
40
+ <span>&nbsp;Use <code>https://</code> instead of <code>http://</code></span>
41
+ </div>
42
+ </script>
43
+
44
+ <script type="text/html" data-help-name="qrusty-server">
45
+ <p>Connection details for a Qrusty priority queue server.</p>
46
+ <p>
47
+ Action nodes reference an instance of this config node and read its
48
+ <code>baseUrl</code> at runtime, so you can switch between environments
49
+ (dev / staging / prod) by swapping the config node rather than editing
50
+ every action node.
51
+ </p>
52
+ <h3>Fields</h3>
53
+ <dl class="message-properties">
54
+ <dt>Host <span class="property-type">string</span></dt>
55
+ <dd>Hostname or IP of the Qrusty server (e.g. <code>localhost</code>).</dd>
56
+ <dt>Port <span class="property-type">number</span></dt>
57
+ <dd>TCP port, typically <code>6784</code>.</dd>
58
+ <dt>HTTPS <span class="property-type">boolean</span></dt>
59
+ <dd>
60
+ When checked, the computed <code>baseUrl</code> uses
61
+ <code>https://</code>; otherwise <code>http://</code>.
62
+ </dd>
63
+ </dl>
64
+ </script>
@@ -0,0 +1,20 @@
1
+ // qrusty-server.js
2
+ //
3
+ // Config node that holds the connection details for a Qrusty server.
4
+ // Action nodes (qrusty-publish, qrusty-consume, etc.) reference a
5
+ // qrusty-server instance and read `baseUrl` from it at runtime.
6
+
7
+ module.exports = function (RED) {
8
+ function QrustyServerNode(n) {
9
+ RED.nodes.createNode(this, n);
10
+ this.name = n.name || "";
11
+ this.host = n.host || "localhost";
12
+ this.port = parseInt(n.port, 10) || 6784;
13
+ this.useHttps = !!n.useHttps;
14
+
15
+ const scheme = this.useHttps ? "https" : "http";
16
+ this.baseUrl = `${scheme}://${this.host}:${this.port}`;
17
+ }
18
+
19
+ RED.nodes.registerType("qrusty-server", QrustyServerNode);
20
+ };
@@ -0,0 +1,37 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType("qrusty-stats", {
3
+ category: "qrusty",
4
+ color: "#b9d18c",
5
+ defaults: {
6
+ name: { value: "" },
7
+ server: { value: "", type: "qrusty-server", required: true },
8
+ },
9
+ inputs: 1,
10
+ outputs: 1,
11
+ icon: "font-awesome/fa-bar-chart",
12
+ label: function () {
13
+ return this.name || "qrusty stats";
14
+ },
15
+ paletteLabel: "stats",
16
+ });
17
+ </script>
18
+
19
+ <script type="text/html" data-template-name="qrusty-stats">
20
+ <div class="form-row">
21
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
+ <input type="text" id="node-input-name" placeholder="optional" />
23
+ </div>
24
+ <div class="form-row">
25
+ <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
26
+ <input type="text" id="node-input-server" />
27
+ </div>
28
+ </script>
29
+
30
+ <script type="text/html" data-help-name="qrusty-stats">
31
+ <p>Fetches aggregate stats for every queue on the server.</p>
32
+ <h3>Outputs</h3>
33
+ <dl class="message-properties">
34
+ <dt>payload <span class="property-type">object</span></dt>
35
+ <dd><code>{ queues: [...] }</code> with per-queue counts and rates.</dd>
36
+ </dl>
37
+ </script>
package/qrusty-stats.js CHANGED
@@ -1,5 +1,19 @@
1
- // Function node for getting stats for all queues in qrusty
2
- msg.url = "http://queue-server:6784/stats";
3
- msg.method = "GET";
4
- msg.headers = { "Content-Type": "application/json" };
5
- return msg;
1
+ // qrusty-stats.js
2
+ //
3
+ // Fetches aggregate stats for every queue on the server.
4
+
5
+ const { setupActionNode } = require("./lib/common");
6
+
7
+ module.exports = function (RED) {
8
+ function QrustyStatsNode(n) {
9
+ RED.nodes.createNode(this, n);
10
+ const node = this;
11
+ const server = RED.nodes.getNode(n.server);
12
+
13
+ setupActionNode(node, server, async (client /*, msg */) => {
14
+ return await client.stats();
15
+ });
16
+ }
17
+
18
+ RED.nodes.registerType("qrusty-stats", QrustyStatsNode);
19
+ };