Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new "transform arguments" API for better key and metadata extraction #2733

Merged
merged 8 commits into from
Oct 31, 2024

Conversation

sjpotter
Copy link
Contributor

@sjpotter sjpotter commented Apr 4, 2024

Builds on #2716

@sjpotter sjpotter force-pushed the cmd-parser-with-commands branch 3 times, most recently from 02245f3 to 93f897d Compare April 4, 2024 11:47
@sjpotter sjpotter force-pushed the cmd-parser-with-commands branch 2 times, most recently from 18e7927 to 2405923 Compare August 12, 2024 09:10
@sjpotter sjpotter changed the base branch from v5 to master October 15, 2024 15:34
return ['COMMAND', 'GETKEYSANDFLAGS', ...args];
parseCommand(parser: CommandParser, args: Array<RedisArgument>) {
parser.push('COMMAND', 'GETKEYSANDFLAGS');
parser.pushVariadic(args);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parser.push(...args)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also no test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved first comment

@@ -1,11 +1,13 @@
import { CommandParser } from '../client/parser';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test

@@ -1,3 +1,4 @@
import { CommandParser } from '../client/parser';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test

@@ -1,10 +1,11 @@
import { CommandParser } from '../client/parser';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test

@sjpotter
Copy link
Contributor Author

General Comment, should add to all tests to validate that proper set of key(s) are processed by the parsing.

...key
);
parser.push('KEYS');
parser.pushVariadic(key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to pushKeys

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't specify key index before, so makes sense why i didn't use pushKeys, but perhaps it should? or perhaps should never be called from a cluster client?

} else {
args.push(key);
parser.push(key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to pushKey()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't specify key index before, so makes sense why i didn't use pushKeys, but perhaps it should? or perhaps should never be called from a cluster client?

Comment on lines +14 to +17
export function parseXAddArguments(
optional: RedisArgument | undefined,
parser: CommandParser,
key: RedisArgument,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ponder optional argument up front if better elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annoying but due to location of NOMKSTREAM (i.e. xadd NOMKSTREAM), I'm not sure of a better way to do it without duplicating code.

firstKey: RedisArgument | undefined;
respVersion: RespVersions;
preserve: unknown;
cachable: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of getter on parser, and just put as part of command struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed on all core commands, never did parser.setCacheable on module commands, will need to determine which need to be cached.

@@ -69,7 +72,7 @@ export interface RedisClusterOptions<
type ClusterCommand<
NAME extends PropertyKey,
COMMAND extends Command
> = COMMAND['FIRST_KEY_INDEX'] extends undefined ? (
> = COMMAND['NOT_KEYED_COMMAND'] extends true ? (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugly, but unsure.

addCommand needs to be there for sendCommand like ability within a multi.

If its there, it might as well be used by createCommand() et al, to avoid repeating code.

addScript is there (even though only used once), but now made private to keep the logic for bookkeeping near each other.
@leibale leibale marked this pull request as ready for review October 31, 2024 16:14
@leibale leibale changed the title Cmd parser with commands new "transform arguments" API to better extract keys Oct 31, 2024
@leibale leibale changed the title new "transform arguments" API to better extract keys new "transform arguments" API for better key and metadata extraction Oct 31, 2024
@leibale leibale merged commit 4708736 into redis:master Oct 31, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants