Skip to content

Commit e9461d3

Browse files
authored
DX-2446: expose TData generic on xrange and xrevrange (#1414)
* feat: expose TData generic on xrange and xrevrange * fix: lint * fix: add sleep before xclaim to satisfy min-idle-time in CI * fix: simplify xrange/xrevrange generic
1 parent 7d1406e commit e9461d3

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

pkg/commands/xclaim.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ describe("XCLAIM", () => {
3030

3131
await new XReadGroupCommand([group, consumer3, [streamKey], [">"], { count: 1 }]).exec(client);
3232

33+
// XCLAIM requires the message to have been idle for at least min-idle-time (100ms)
34+
await new Promise((r) => setTimeout(r, 150));
35+
3336
const res = (await new XClaimCommand([streamKey, group, consumer3, 100, streamId2]).exec(
3437
client
3538
)) as string[];

pkg/pipeline.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,14 +1302,15 @@ export class Pipeline<TCommands extends Command<any, any>[] = []> {
13021302
/**
13031303
* @see https://redis.io/commands/xrange
13041304
*/
1305-
xrange = (...args: CommandArgs<typeof XRangeCommand>) =>
1306-
this.chain(new XRangeCommand(args, this.commandOptions));
1305+
xrange = <TData extends Record<string, unknown>>(...args: CommandArgs<typeof XRangeCommand>) =>
1306+
this.chain(new XRangeCommand<Record<string, TData>>(args, this.commandOptions));
13071307

13081308
/**
13091309
* @see https://redis.io/commands/xrevrange
13101310
*/
1311-
xrevrange = (...args: CommandArgs<typeof XRevRangeCommand>) =>
1312-
this.chain(new XRevRangeCommand(args, this.commandOptions));
1311+
xrevrange = <TData extends Record<string, unknown>>(
1312+
...args: CommandArgs<typeof XRevRangeCommand>
1313+
) => this.chain(new XRevRangeCommand<Record<string, TData>>(args, this.commandOptions));
13131314

13141315
/**
13151316
* @see https://redis.io/commands/zcard

pkg/redis.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,14 +1471,15 @@ export class Redis {
14711471
/**
14721472
* @see https://redis.io/commands/xrange
14731473
*/
1474-
xrange = (...args: CommandArgs<typeof XRangeCommand>) =>
1475-
new XRangeCommand(args, this.opts).exec(this.client);
1474+
xrange = <TData extends Record<string, unknown>>(...args: CommandArgs<typeof XRangeCommand>) =>
1475+
new XRangeCommand<Record<string, TData>>(args, this.opts).exec(this.client);
14761476

14771477
/**
14781478
* @see https://redis.io/commands/xrevrange
14791479
*/
1480-
xrevrange = (...args: CommandArgs<typeof XRevRangeCommand>) =>
1481-
new XRevRangeCommand(args, this.opts).exec(this.client);
1480+
xrevrange = <TData extends Record<string, unknown>>(
1481+
...args: CommandArgs<typeof XRevRangeCommand>
1482+
) => new XRevRangeCommand<Record<string, TData>>(args, this.opts).exec(this.client);
14821483

14831484
/**
14841485
* @see https://redis.io/commands/zadd

0 commit comments

Comments
 (0)