Repository navigation
v4 design: generated scripts and functions - #3401
Merged
Merged
Conversation
A shape for declaring server-side code as partial methods: binding by name, shared call shape, per-kind provisioning; facts checked against Redis 8.12.
…RespCommandGenerator
…ore of the declared-command model
mgravell
marked this pull request as ready for review
December 3, 2026 15:03
pairbit
added a commit
to pairbit/IT.Redis
that referenced
this pull request
Dec 3, 2026
* v4 design: generated scripts and functions (seredis#3401) * design: generated scripts and functions (exploratory) A shape for declaring server-side code as partial methods: binding by name, shared call shape, per-kind provisioning; facts checked against Redis 8.12. * design: functions are opaque names; administration on IServer, not in the pipeline * design: lists of keys and arguments, and how a script sees them * design: the general case - declared commands, after the marc/respite RespCommandGenerator * design: keyword clauses (prefix, suffix, count, ignore-when) as the core of the declared-command model * v4: Redis 8.12 test topology (cluster bus protected mode, ZSCAN duplicates), from main's seredis#3343 (seredis#3399) * CI (Windows): let Redis 8.12 start the cluster nodes 8.12 refuses a cluster node with an unauthenticated bus port unless cluster-bus-port-protected-mode is off; older servers reject the option, so it is passed only to 8.12 and later. * Redis 8.12 test topology, ported from main's seredis#3343: cluster-bus-port-protected-mode in the cluster confs, client-libs-test:8.12.0, and ZSCAN may return duplicates Replaces the version-gated CI.yml option: main already solves this in the cluster confs, and v4 follows it. * v4 Scripts: build the NOSCRIPT retry from the rendered EVALSHA, not the caller's spans (seredis#3398) * Scripts: build the NOSCRIPT retry from the rendered EVALSHA, not the caller's spans The repair captured keys/args with ToArray() whenever the send had not completed synchronously. That copied the RedisValues but not the memory under them, so a caller who returned a pooled buffer after the call returned had the retry send whatever was there by the time NOSCRIPT arrived; and it cost two arrays on almost every real call. The retry now holds a reference to the rendered EVALSHA (a reference count, no copy) and re-renders EVAL from its arguments through the command map, without re-applying the key prefix the keys already carry. * SendWithPreambleAsync: the gate and cancellation token are required, not defaulted Internal, so correctness wins over convenience: a caller that forgets to pass its token should not compile. --------- Co-authored-by: Marc Gravell <marc.gravell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An exploratory design for the idea from #3364: declare a script or function as a
partialmethod, and have the generator write the call. It's a design note only, with no code, following the "ideas, not decisions" convention ofdesign/.What it proposes:
Two layers. Binding is shared: the signature, key/arg split, reply handler, and a method body that renders
<call> <id> numkeys keys... args.... The kind decides the call command and what happens when the server doesn't have the code.Scripts: a Lua body with parameters bound by name (
@key,@count), rewritten at build time so the hash is a constant. The client provisions on demand as it does today (SCRIPT LOADpaired withEVALSHA). TheNOSCRIPTrepair works from the sent frame, which relies on v4 Scripts: build the NOSCRIPT retry from the rendered EVALSHA, not the caller's spans #3398, so generated code never holds argument arrays.Functions are opaque names. A
[RedisFunction("name", ReadOnly = ...)]declaration has no body and binds positionally. It sendsFCALL/FCALL_RO, andERR Function not foundis reported, never repaired. Loading is a deployment concern.FUNCTION LOADand the other administration commands go onIServer, outside the execution pipeline, which also settles the deferredFUNCTION *rows in the coverage ledger (Missing Commands in StackExchange.Redis #2055).The general case (§9). The
marc/respitespike'sRespCommandGeneratordeclared every command as apartialmethod ([RespCommand],[RespPrefix]for literals and counts,[RespIgnore]for optional clauses). The proposal is to retarget that model at v4's builder, make it public for ad-hoc and module commands, and build scripts and functions as specialisations of it. It isn't proposed as a replacement for v4's hand-written methods, which are already one-liners.Open questions are in §11. Mainly: the public runtime surface the generated code calls, variable-length key and argument lists, and the shape of the
IServeradministration API. §12 has a suggested order of work.