feat: add more rules for parsing#7767
Conversation
🤖 Augment PR SummarySummary: This PR extends Changes:
Technical Notes: Parser errors still latch on first failure; empty rule messages keep generic 🤖 Was this summary useful? React with 👍 or 👎 |
Code Review by Qodo
1. Invalid decltype member access
|
| width = parser.Next<uint32_t>(); | ||
| depth = parser.Next<uint32_t>(); | ||
| decay = parser.Next<double>(); | ||
| decay = parser.Next<Validated<double, Bounded<0.0, 1.0, kDecayRangeErr>>>(); |
There was a problem hiding this comment.
looks cool, but probably using some kind of builder pattern (in the type world) would be more readable
There was a problem hiding this comment.
I want it to be short to read easily. Parsing isn't important logic so I want to make it as simple and declarative as much as possible to allow concentration on the important logic. If you see how to improve my approach, I will be happy to do it.
|
augment review |
48bb27b to
1ff8911
Compare
|
augment review |
1ff8911 to
4fd3974
Compare
PR Summary by Qodo
Add composable validation rules to CmdArgParser and refactor command parsing
✨ Enhancement🧪 Tests🕐 40+ MinutesAI Description
Diagram
graph TD A["Server commands"] --> B["CmdArgParser"] --> C["Convert/Next<T>"] --> D["Validated<T, Rules...>"] --> E["Rules (RuleError)"] B --> F["ErrorInfo / replies"] G["CmdArgParser tests"] --> D E --> F subgraph Legend direction LR _cmd["Command handler"] ~~~ _core["Core parser"] ~~~ _rule["Validation rule"] endHigh-Level Assessment
1. Return std::expected from reads
2. Use a concept/traits-based validator interface (no NTTP function pointers)
Files changed (14)
+253 / -153Enhancement (2)
+75 / -21cmd_arg_parser.h
Introduce RuleError/Validated framework and reusable numeric rules+74/-21error.h
Add dedicated timeout-negative error string+1/-0Refactor (11)
+54 / -128bitops_family.cc
Enforce BITPOS bit arg via Validated and simplify optional args+5/-33bloom_family.cc
Use FInt for bloom cursor bounds+3/-10cuckoo_filter_family.cc
Move CF business-rule bounds into Validated rules+13/-22generic_family.cc
Use FInt for RESTORE ttl and NextOrDefault for PING message+3/-6hset_family.cc
Validate HINCRBYFLOAT input as finite during parse+1/-5list_family.cc
Centralize timeout/count parsing via Validated and NextOrDefault+5/-18search_family.cc
Adapt search numeric validators to RuleError semantics+13/-12set_family.cc
Simplify SRANDMEMBER count parsing via NextOrDefault+1/-1string_family.cc
Prevent INT64_MIN overflow in DECRBY via Validated rule+1/-5topk_family.cc
Validate TOPK decay/increment ranges during parsing+6/-9zset_family.cc
Validate NaN score and simplify ZRANDMEMBER count defaulting+3/-7Tests (1)
+124 / -4cmd_arg_parser_test.cc
Add coverage for Validated rules and migrate existing validator+124/-4