1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Update stream-consumer.js

This commit is contained in:
Leibale Eidelman
2022-01-13 12:01:41 -05:00
committed by GitHub
parent 309cdbdd7c
commit 8a40398a75

View File

@@ -16,7 +16,7 @@ async function streamConsumer() {
commandOptions({ commandOptions({
isolated: true isolated: true
}), [ }), [
// XREAD can read from multiple streams, starting at a // XREAD can read from multiple streams, starting at a
// different ID for each... // different ID for each...
{ {
key: 'mystream', key: 'mystream',
@@ -33,7 +33,7 @@ async function streamConsumer() {
// Response is an array of streams, each containing an array of // Response is an array of streams, each containing an array of
// entries: // entries:
// [ // [
// { // {
// "name": "mystream", // "name": "mystream",
// "messages": [ // "messages": [
// { // {
@@ -49,17 +49,16 @@ async function streamConsumer() {
// Get the ID of the first (only) entry returned. // Get the ID of the first (only) entry returned.
currentId = response[0].messages[0].id; currentId = response[0].messages[0].id;
console.log(currentId); console.log(currentId);
} else { } else {
// Response is null, we have read everything that is // Response is null, we have read everything that is
// in the stream right now... // in the stream right now...
console.log('No new stream entries.'); console.log('No new stream entries.');
} }
} catch (err) {
console.error(err);
} }
} catch (err) {
console.error(err);
} }
} }
streamConsumer(); streamConsumer();