qrusty-client
v0.17.6
Published
Node.js client for the qrusty priority queue server API.
Readme
qrusty-client
Node.js client for the qrusty priority queue server API.
Features
- Connect to a qrusty server
- Publish, consume, ack, and purge messages
- List and manage queues
- Promise-based API using axios
- WebSocket client (
WsSession) for push-based delivery
Installation
npm install qrusty-clientUsage
HTTP client
const { QrustyClient } = require("qrusty-client");
const client = new QrustyClient("http://localhost:6784");
(async () => {
await client.createQueue("orders", "MaxFirst", true);
await client.publish("orders", 100, { order_id: 123 });
// Text priorities are also supported for queues with priority_kind: "Text"
await client.createQueue("tags", "MinFirst", true, "Text");
await client.publish("tags", "alpha", { tag: "first" });
const msg = await client.consume("orders", "worker-1");
if (msg) {
await client.ack("orders", msg.id, "worker-1");
}
})();WebSocket client
const { WsSession } = require("qrusty-client");
(async () => {
const session = new WsSession("ws://localhost:6784");
await session.connect();
const id = await session.publish("orders", "hello", 10);
for await (const msg of session.subscribe("orders")) {
console.log(msg.payload);
await session.ack(msg.queue, msg.id);
break; // or keep processing
}
await session.close();
})();If the server closes the connection, all pending publish/ack/nack calls
reject immediately and any active subscribe iterators stop iterating.
Documentation
Generate HTML docs with:
npm run docsTesting
Run unit tests with:
npm testPublishing
Log in to npm (if you haven't):
npm loginPublish the package:
npm publish
Credentials Needed
- You need an npm account (https://www.npmjs.com/)
- Run
npm loginand enter your username, password, and email - This stores your credentials in
~/.npmrcfor publishing
License
MIT
