@axiom-lattice/queue-redis
v1.0.12
Published
Redis queue client implementation for Axiom Lattice framework
Maintainers
Readme
@axiom-lattice/queue-redis
Redis queue client implementation for the Axiom Lattice framework.
Overview
This package provides a Redis-based queue client implementation that conforms to the QueueClient interface defined in @axiom-lattice/protocols. It can be used with the QueueLatticeManager from @axiom-lattice/core to register and manage Redis-based queue services.
Installation
pnpm add @axiom-lattice/queue-redisUsage
Basic Usage
import { RedisQueueClient } from "@axiom-lattice/queue-redis";
import { registerQueueLattice } from "@axiom-lattice/core";
import { QueueType } from "@axiom-lattice/protocols";
// Register Redis queue service
registerQueueLattice("redis-queue", {
name: "Redis Queue Service",
description: "Redis-based queue service",
type: QueueType.REDIS,
queueName: "tasks",
options: {
redisUrl: process.env.REDIS_URL || "redis://localhost:6379",
redisPassword: process.env.REDIS_PASSWORD,
},
});
// Get and use the queue
import { getQueueLattice } from "@axiom-lattice/core";
const queue = getQueueLattice("redis-queue");
// Push item to queue
await queue.push({ task: "example" });
// Pop item from queue
const result = await queue.pop();Direct Usage
import { RedisQueueClient } from "@axiom-lattice/queue-redis";
const client = new RedisQueueClient("tasks", {
redisUrl: "redis://localhost:6379",
redisPassword: "your-password",
});
// Push item
await client.push({ data: "example" });
// Pop item
const result = await queue.pop();Configuration
The Redis queue client can be configured via:
- Constructor options: Pass
redisUrlandredisPassworddirectly - Environment variables:
REDIS_URL(default:redis://localhost:6379)REDIS_PASSWORD(optional)
License
MIT
