Skip to content

Commit aef901e

Browse files
committed
tweak unstable search module flag name + add proper error message
1 parent 2ac0964 commit aef901e

File tree

14 files changed

+19
-24
lines changed

14 files changed

+19
-24
lines changed

packages/client/lib/RESP/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export type Command = {
281281
transformArguments(this: void, ...args: Array<any>): CommandArguments;
282282
TRANSFORM_LEGACY_REPLY?: boolean;
283283
transformReply: TransformReply | Record<RespVersions, TransformReply>;
284-
unstableResp3Module?: boolean;
284+
unstableResp3SearchModule?: boolean;
285285
};
286286

287287
export type RedisCommands = Record<string, Command>;
@@ -315,7 +315,7 @@ export interface CommanderConfig<
315315
/**
316316
* TODO
317317
*/
318-
unstableResp3Modules?: boolean;
318+
unstableResp3SearchModule?: boolean;
319319
}
320320

321321
type Resp2Array<T> = (

packages/client/lib/cluster/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface RedisClusterOptions<
6666
/**
6767
* TODO
6868
*/
69-
unstableResp3Modules?: boolean;
69+
unstableResp3SearchModule?: boolean;
7070
}
7171

7272
// remove once request & response policies are ready

packages/client/lib/commander.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ interface AttachConfigOptions<
1616
}
1717

1818
/* FIXME: better error message / link */
19-
function throwResp3ModuleUnstableError() {
20-
throw new Error("unstable resp3 module, client not configured with proper flag");
19+
function throwResp3SearchModuleUnstableError() {
20+
throw new Error('Some RESP3 results for Redis Query Engine responses may change. Refer to the readme for guidance');
2121
}
2222

2323
export function attachConfig<
@@ -45,8 +45,8 @@ export function attachConfig<
4545
for (const [moduleName, module] of Object.entries(config.modules)) {
4646
const fns = Object.create(null);
4747
for (const [name, command] of Object.entries(module)) {
48-
if (config.RESP == 3 && command.unstableResp3Module && !config.unstableResp3Modules) {
49-
fns[name] = throwResp3ModuleUnstableError;
48+
if (config.RESP == 3 && command.unstableResp3SearchModule && !config.unstableResp3SearchModule) {
49+
fns[name] = throwResp3SearchModuleUnstableError;
5050
} else {
5151
fns[name] = createModuleCommand(command, RESP);
5252
}

packages/client/lib/sentinel/multi-commands.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import COMMANDS from '../commands';
22
import RedisMultiCommand, { MULTI_REPLY, MultiReply, MultiReplyType } from '../multi-command';
33
import { ReplyWithTypeMapping, CommandReply, Command, CommandArguments, CommanderConfig, RedisFunctions, RedisModules, RedisScripts, RespVersions, TransformReply, RedisScript, RedisFunction, TypeMapping } from '../RESP/types';
44
import { attachConfig, functionArgumentsPrefix, getTransformReply } from '../commander';
5-
import { RedisSentinelOptions, RedisSentinelType } from './types';
5+
import { RedisSentinelType } from './types';
66

77
type CommandSignature<
88
REPLIES extends Array<unknown>,
@@ -100,9 +100,6 @@ export default class RedisSentinelMultiCommand<REPLIES = []> {
100100
private static _createModuleCommand(command: Command, resp: RespVersions) {
101101
const transformReply = getTransformReply(command, resp);
102102
return function (this: { _self: RedisSentinelMultiCommand }, ...args: Array<unknown>) {
103-
if (command.unstableResp3Module && resp == 3 && !this._self.#options?.unstableResp3Modules) {
104-
throw new Error("unstable resp3 module, client not configured with proper flag");
105-
}
106103
const redisArgs = command.transformArguments(...args);
107104
return this._self.addCommand(
108105
command.IS_READ_ONLY,
@@ -163,11 +160,9 @@ export default class RedisSentinelMultiCommand<REPLIES = []> {
163160
private readonly _multi = new RedisMultiCommand();
164161
private readonly _sentinel: RedisSentinelType
165162
private _isReadonly: boolean | undefined = true;
166-
readonly #options?: RedisSentinelOptions;
167163

168-
constructor(sentinel: RedisSentinelType, options?: RedisSentinelOptions) {
164+
constructor(sentinel: RedisSentinelType) {
169165
this._sentinel = sentinel;
170-
this.#options = options;
171166
}
172167

173168
private _setState(

packages/client/lib/sentinel/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface RedisSentinelOptions<
6262
/**
6363
* TODO
6464
*/
65-
unstableResp3Modules?: boolean;
65+
unstableResp3SearchModule?: boolean;
6666
}
6767

6868
export interface SentinelCommander<

packages/search/lib/commands/AGGREGATE.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default {
159159
},
160160
3: undefined as unknown as () => ReplyUnion
161161
},
162-
unstableResp3Module: true
162+
unstableResp3SearchModule: true
163163
} as const satisfies Command;
164164

165165
export function pushAggregateOptions(args: Array<RedisArgument>, options?: FtAggregateOptions) {

packages/search/lib/commands/AGGREGATE_WITHCURSOR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ export default {
4242
},
4343
3: undefined as unknown as () => ReplyUnion
4444
},
45-
unstableResp3Module: true
45+
unstableResp3SearchModule: true
4646
} as const satisfies Command;
4747

packages/search/lib/commands/CURSOR_READ.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export default {
1818
return args;
1919
},
2020
transformReply: AGGREGATE_WITHCURSOR.transformReply,
21-
unstableResp3Module: true
21+
unstableResp3SearchModule: true
2222
} as const satisfies Command;

packages/search/lib/commands/INFO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
2: transformV2Reply,
1313
3: undefined as unknown as () => ReplyUnion
1414
},
15-
unstableResp3Module: true
15+
unstableResp3SearchModule: true
1616
} as const satisfies Command;
1717

1818
type InfoRawReply = [

packages/search/lib/commands/PROFILE_AGGREGATE.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
},
3333
3: undefined as unknown as () => ReplyUnion
3434
},
35-
unstableResp3Module: true
35+
unstableResp3SearchModule: true
3636
} as const satisfies Command;
3737

3838
type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;

0 commit comments

Comments
 (0)