2.1.6 • Published 5 months ago

@nelreina/redis-stream-consumer v2.1.6

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

@nelreina/redis-stream-consumer

A simple redis-streams consumer package with auto ack

Usage

import RedisStreamConsumer from "@nelreina/redis-stream-consumer";
const stream = await RedisStreamConsumer(redisClient, KEY, GROUP_NAME, options);

Example

import { createClient } from "redis";
import RedisStreamConsumer from "@nelreina/redis-stream-consumer";

const url = process.env.REDIS_URL;

export const client = createClient({ url });
await client.connect();

// Minimal Setup
const stream = await RedisStreamConsumer(
  client,
  "example:key",
  "exampleGroup"
  // options = {
  //  consumer: os.hostname()
  //  autoAck: false
  //  startID: "$" begin at next entry / 0 from beginning
  // }
);

const callback = async (id, message, ack) => {
  console.log(message);
  // Here your code to process stream message
};

if (stream.listen) {
  stream.listen(callback);
}

Options

NameTypeDefault
consumerstringos.hostname()
autoAckbooleanfalse
startIDstring$
loggerfunctionconsole

Acknowledge Stream Message

if autoAck is false / remember to acknowledge stream message

  stream.ack(<stream_id>);

Run the example

  • tested on node version v16.15.0
  • Redis client v4.x
  • Uses nodejs type module
git clone https://github.com/nelreina/redis-stream-consumer.git
cd redis-stream-consumer
npm i
npm run dev
2.1.6

5 months ago

2.1.5

5 months ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.3.0

2 years ago

1.1.2

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago