Commit d1ccf7e
feat(client): wire multi_shard splitter into cluster dispatch
Make the multi_shard request policy actually split commands per hash
slot instead of sending the full command to one client per key.
- Routers now return a plan (RoutedCommand[]) rather than bare clients:
pass-through policies set `client`; routeMultiShard calls the splitter
and builds a sub-parser per slot (buildSubParser marks keys at the
splitter's new keyPositions so `firstKey` routes each sub-command).
- The engine runs each plan entry through core `_execute` with its own
sub-parser, so every shard gets its own sub-args; MOVED/ASK use the
sub-command's key.
- Response reducers gain optional positionHints; reduceDefaultKeyed
scatters split replies by groupIndices so MGET preserves caller key
order across slots. Aggregating reducers (agg_sum, all_succeeded)
ignore the hint.
- Splitter SubCommand now carries keyPositions for sub-parser key
marking.
Also merge _executePolicyPlan into _executeWithPolicies — the old name
implied a plan object that never existed; it is now the single engine
(resolve policy -> plan -> execute -> reduce).
Router/reducer types are intentionally non-generic (routing sits below
the typed command surface; clients are opaque pass-through), erased to
the base cluster types instead of `any`; the engine re-narrows the
client at the `_execute` boundary.
Working end-to-end: DEL/UNLINK/EXISTS/TOUCH, MSET/MSETEX, MGET. Raw
sendCommand multi_shard and cluster-docker integration tests remain.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent d83ec08 commit d1ccf7e
5 files changed
Lines changed: 251 additions & 112 deletions
File tree
- packages/client/lib/cluster
- request-response-policies
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
174 | 175 | | |
175 | | - | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
190 | 191 | | |
191 | | - | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | | - | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
| 226 | + | |
226 | 227 | | |
227 | | - | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
| 455 | + | |
455 | 456 | | |
456 | 457 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | 458 | | |
486 | 459 | | |
487 | 460 | | |
| |||
503 | 476 | | |
504 | 477 | | |
505 | 478 | | |
506 | | - | |
507 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
508 | 487 | | |
509 | | - | |
| 488 | + | |
510 | 489 | | |
511 | 490 | | |
512 | 491 | | |
513 | | - | |
514 | | - | |
515 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
516 | 498 | | |
517 | 499 | | |
518 | 500 | | |
519 | 501 | | |
520 | 502 | | |
521 | | - | |
| 503 | + | |
| 504 | + | |
522 | 505 | | |
523 | 506 | | |
524 | 507 | | |
525 | 508 | | |
526 | 509 | | |
527 | 510 | | |
528 | | - | |
| 511 | + | |
529 | 512 | | |
530 | 513 | | |
531 | 514 | | |
| |||
621 | 604 | | |
622 | 605 | | |
623 | 606 | | |
624 | | - | |
| 607 | + | |
625 | 608 | | |
626 | 609 | | |
627 | 610 | | |
628 | 611 | | |
629 | | - | |
| 612 | + | |
630 | 613 | | |
631 | 614 | | |
632 | 615 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
0 commit comments