corinth.js

Node.js wrapper for Corinth, a Rust message queue server.

Usage no npm install needed!

<script type="module">
  import corinthJs from 'https://cdn.skypack.dev/corinth.js';
</script>

README

Corinth.js

Node.js wrapper for Corinth, a Rust message queue server.

codecov CI & Coverage

Example

import { Corinth } from "corinth.js";

const hostUrl = "http://localhost:44444";
const corinth = new Corinth(hostUrl);

interface IItem {
  id: string;
}

// myQueue contains IItem objects
// This does not create the queue, just defines a model to interact with
const myQueue = corinth.defineQueue<IItem>("myQueue");

// Ensure queue exists
await myQueue.ensure();

// Enqueue an item
await myQueue.enqueueOne({ id: "abc" });

// Get one or more items from the queue
// Gets one by default
const result = await myQueue.dequeue();
const message = result[0];

// Process your item
await processItem(message.item);

// Acknowledge success
await message.ack();