Cora QueueClient v0.1.0
QueueClient
is a powerful TypeScript class designed to streamline interactions with the Cora queue service described here using the popular Axios library.
This client serves as an intuitive interface for developers who need to manage queue operations effectively, providing a comprehensive suite of features to handle various queue-related tasks seamlessly.
📚 Table of Contents
- Installation 🚀
- Usage 📖
Installation
Install Axios in your project:
npm install axios
Usage
Importing
import {
QueueClient,
QueueItem,
CreateQueueResponse,
EnqueueResponse,
DequeueResponse,
ScanResponse,
} from "cora-sdk";
Creating an Instance
const queueClient = new QueueClient("http://localhost:8080");
Creating a Queue
const createQueueResponse: CreateQueueResponse = await queueClient.createQueue(
"myQueue"
);
Enqueuing an Item
const item: QueueItem = {
id: "item-id-1",
payload: JSON.stringify({ name: "My Item" }),
priority: 1,
};
const enqueueResponse: EnqueueResponse = await queueClient.enqueue(
"myQueue",
item
);
Dequeuing an Item
const dequeueResponse: DequeueResponse = await queueClient.dequeue("myQueue");
Scanning a Queue
const scanResponse: ScanResponse = await queueClient.scan("myQueue");