You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { Command, RedisArgument, ReplyUnion } from '../RESP/types';
|
|
import { transformStreamsMessagesReplyResp2 } from './generic-transformers';
|
|
import XREAD, { XReadStreams, pushXReadStreams } from './XREAD';
|
|
|
|
export interface XReadGroupOptions {
|
|
COUNT?: number;
|
|
BLOCK?: number;
|
|
NOACK?: boolean;
|
|
}
|
|
|
|
export default {
|
|
FIRST_KEY_INDEX(
|
|
_group: RedisArgument,
|
|
_consumer: RedisArgument,
|
|
streams: XReadStreams
|
|
) {
|
|
return XREAD.FIRST_KEY_INDEX(streams);
|
|
},
|
|
IS_READ_ONLY: true,
|
|
transformArguments(
|
|
group: RedisArgument,
|
|
consumer: RedisArgument,
|
|
streams: XReadStreams,
|
|
options?: XReadGroupOptions
|
|
) {
|
|
const args = ['XREADGROUP', 'GROUP', group, consumer];
|
|
|
|
if (options?.COUNT !== undefined) {
|
|
args.push('COUNT', options.COUNT.toString());
|
|
}
|
|
|
|
if (options?.BLOCK !== undefined) {
|
|
args.push('BLOCK', options.BLOCK.toString());
|
|
}
|
|
|
|
if (options?.NOACK) {
|
|
args.push('NOACK');
|
|
}
|
|
|
|
pushXReadStreams(args, streams);
|
|
|
|
return args;
|
|
},
|
|
transformReply: {
|
|
2: transformStreamsMessagesReplyResp2,
|
|
3: undefined as unknown as () => ReplyUnion
|
|
},
|
|
unstableResp3: true,
|
|
} as const satisfies Command;
|