You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
* fix(client): XCLAIM & XAUTOCLAIM after a TRIM might return nils * fix(client): Fix race condition in specs * revert test utils changes * make tests faster --------- Co-authored-by: Leibale Eidelman <me@leibale.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { RedisArgument, TuplesReply, BlobStringReply, ArrayReply, NullReply, UnwrapReply, Command } from '../RESP/types';
|
|
import { StreamMessageReply, transformStreamMessageNullReply } from './generic-transformers';
|
|
|
|
export interface XAutoClaimOptions {
|
|
COUNT?: number;
|
|
}
|
|
|
|
export type XAutoClaimRawReply = TuplesReply<[
|
|
nextId: BlobStringReply,
|
|
messages: ArrayReply<StreamMessageReply | NullReply>,
|
|
deletedMessages: ArrayReply<BlobStringReply>
|
|
]>;
|
|
|
|
export default {
|
|
FIRST_KEY_INDEX: 1,
|
|
IS_READ_ONLY: false,
|
|
transformArguments(
|
|
key: RedisArgument,
|
|
group: RedisArgument,
|
|
consumer: RedisArgument,
|
|
minIdleTime: number,
|
|
start: RedisArgument,
|
|
options?: XAutoClaimOptions
|
|
) {
|
|
const args = [
|
|
'XAUTOCLAIM',
|
|
key,
|
|
group,
|
|
consumer,
|
|
minIdleTime.toString(),
|
|
start
|
|
];
|
|
|
|
if (options?.COUNT) {
|
|
args.push('COUNT', options.COUNT.toString());
|
|
}
|
|
|
|
return args;
|
|
},
|
|
transformReply(reply: UnwrapReply<XAutoClaimRawReply>) {
|
|
return {
|
|
nextId: reply[0],
|
|
messages: (reply[1] as unknown as UnwrapReply<typeof reply[1]>).map(transformStreamMessageNullReply),
|
|
deletedMessages: reply[2]
|
|
};
|
|
}
|
|
} as const satisfies Command;
|