Skip to content

Commit

Permalink
Fix XINFO for review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
  • Loading branch information
acarbonetto committed Aug 7, 2024
1 parent 23400ef commit 6af2cab
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 45 deletions.
4 changes: 4 additions & 0 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ function initialize() {
ExecAbortError,
RedisError,
ReturnType,
StreamEntries,
ReturnTypeXinfoStream,
RequestError,
TimeoutError,
ConnectionError,
Expand Down Expand Up @@ -199,6 +201,8 @@ function initialize() {
FunctionStatsResponse,
SlotIdTypes,
SlotKeyTypes,
StreamEntries,
ReturnTypeXinfoStream,
RouteByAddress,
Routes,
SingleNodeRoute,
Expand Down
88 changes: 45 additions & 43 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4035,59 +4035,61 @@ export class BaseClient {
* @param fullOptions - If `true`, returns verbose information with a limit of the first 10 PEL entries.
* If `number` is specified, returns verbose information limiting the returned PEL entries.
* If `0` is specified, returns verbose information with no limit.
* @returns A `Record` of detailed stream information for the given `key`. See
* @returns A {@link ReturnTypeXinfoStream} of detailed stream information for the given `key`. See
* the example for a sample response.
* @example
* ```typescript
* const infoResult = await client.xinfoStream("my_stream");
* console.log(infoResult); // Output: {
* // length: 2,
* // 'radix-tree-keys': 1,
* // 'radix-tree-nodes': 2,
* // 'last-generated-id': '1719877599564-1',
* // 'max-deleted-entry-id': '0-0',
* // 'entries-added': 2,
* // 'recorded-first-entry-id': '1719877599564-0',
* // 'first-entry': [ '1719877599564-0', ['some_field", "some_value', ...] ],
* // 'last-entry': [ '1719877599564-0', ['some_field", "some_value', ...] ],
* // groups: 1,
* // }
* console.log(infoResult);
* // Output: {
* // length: 2,
* // 'radix-tree-keys': 1,
* // 'radix-tree-nodes': 2,
* // 'last-generated-id': '1719877599564-1',
* // 'max-deleted-entry-id': '0-0',
* // 'entries-added': 2,
* // 'recorded-first-entry-id': '1719877599564-0',
* // 'first-entry': [ '1719877599564-0', ['some_field", "some_value', ...] ],
* // 'last-entry': [ '1719877599564-0', ['some_field", "some_value', ...] ],
* // groups: 1,
* // }
* ```
*
* @example
* ```typescript
* const infoResult = await client.xinfoStream("my_stream", true); // default limit of 10 entries
* const infoResult = await client.xinfoStream("my_stream", 15); // limit of 15 entries
* console.log(infoResult); // Output: {
* // length: 2,
* // 'radix-tree-keys': 1,
* // 'radix-tree-nodes': 2,
* // 'last-generated-id': '1719877599564-1',
* // 'max-deleted-entry-id': '0-0',
* // 'entries-added': 2,
* // 'recorded-first-entry-id': '1719877599564-0',
* // entries: [ [ '1719877599564-0', ['some_field", "some_value', ...] ] ],
* // groups: [ {
* // name: 'group',
* // 'last-delivered-id': '1719877599564-0',
* // 'entries-read': 1,
* // lag: 1,
* // 'pel-count': 1,
* // pending: [ [ '1719877599564-0', 'consumer', 1722624726802, 1 ] ],
* // consumers: [ {
* // name: 'consumer',
* // 'seen-time': 1722624726802,
* // 'active-time': 1722624726802,
* // 'pel-count': 1,
* // pending: [ [ '1719877599564-0', 'consumer', 1722624726802, 1 ] ],
* // }
* // ]
* // }
* // ]
* // }
* ```
*/
public xinfoStream(
* console.log(infoResult);
* // Output: {
* // length: 2,
* // 'radix-tree-keys': 1,
* // 'radix-tree-nodes': 2,
* // 'last-generated-id': '1719877599564-1',
* // 'max-deleted-entry-id': '0-0',
* // 'entries-added': 2,
* // 'recorded-first-entry-id': '1719877599564-0',
* // entries: [ [ '1719877599564-0', ['some_field", "some_value', ...] ] ],
* // groups: [ {
* // name: 'group',
* // 'last-delivered-id': '1719877599564-0',
* // 'entries-read': 1,
* // lag: 1,
* // 'pel-count': 1,
* // pending: [ [ '1719877599564-0', 'consumer', 1722624726802, 1 ] ],
* // consumers: [ {
* // name: 'consumer',
* // 'seen-time': 1722624726802,
* // 'active-time': 1722624726802,
* // 'pel-count': 1,
* // pending: [ [ '1719877599564-0', 'consumer', 1722624726802, 1 ] ],
* // }
* // ]
* // }
* // ]
* // }
* ```
*/
public async xinfoStream(
key: string,
fullOptions?: boolean | number,
): Promise<ReturnTypeXinfoStream> {
Expand Down
6 changes: 4 additions & 2 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import {
BaseClient, // eslint-disable-line @typescript-eslint/no-unused-vars
ReadFrom, // eslint-disable-line @typescript-eslint/no-unused-vars
} from "./BaseClient";

Expand Down Expand Up @@ -42,6 +43,7 @@ import {
RangeByIndex,
RangeByLex,
RangeByScore,
ReturnTypeXinfoStream, // eslint-disable-line @typescript-eslint/no-unused-vars
ScoreBoundary,
ScoreFilter,
SearchOrigin,
Expand Down Expand Up @@ -2228,8 +2230,8 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
* If `number` is specified, returns verbose information limiting the returned PEL entries.
* If `0` is specified, returns verbose information with no limit.
*
* Command Response - A `Record` of detailed stream information for the given `key`. See
* the example for a sample response.
* Command Response - A {@link ReturnTypeXinfoStream} of detailed stream information for the given `key`.
* See example of {@link BaseClient.xinfoStream} for more details.
*/
public xinfoStream(key: string, fullOptions?: boolean | number): T {
return this.addAndReturn(createXInfoStream(key, fullOptions ?? false));
Expand Down

0 comments on commit 6af2cab

Please sign in to comment.