Skip to main content

Crate kevy_lua

Crate kevy_lua 

Source
Expand description

kevy-lua — Redis EVAL / EVALSHA / SCRIPT surface backed by luna-core.

kevy’s v1.27 script-host layer. Thin “cement” crate (per the stone-cement-stone model) — it carries no algorithmic content, only the bridge between kevy-rt’s command dispatch path, kevy-resp’s wire codec, and luna-core’s sandboxed Vm.

Design lock-in (see .claude/rfcs/2026-06-23-v1.27-luna-bridge.md):

  • Default Lua 5.1 — preserves the Redis Lua ecosystem (BullMQ, Redlock, rate limiters, anything copied from Redis docs).
  • Per-script dialect opt-in via #!lua version=N — scripts opt into 5.2 / 5.3 / 5.4 / 5.5 with a single shebang line. SHA1 cache key is the raw script bytes, so EVALSHA is version-aware for free.
  • VM per-shard, per-dialect, lazily spawned — first EVAL hitting a dialect on a shard constructs the VM; reused afterwards. Idle RSS scales with dialects actually used.
  • Atomic execution — entering EVAL pauses other dispatch on that shard until the script returns. Matches Redis semantics.

§Phase status — P1

  • Bridge holds a per-dialect Vm pool (lazy-spawned).
  • eval() runs the script under the default 5.1 sandbox and marshals the first returned Value into a RESP reply.
  • Shebang parsing, SHA1 cache, EVALSHA, SCRIPT LOAD/EXISTS/FLUSH, and redis.call host plumbing land in P2-P5 per the RFC.

Modules§

sha1
SHA-1 digest helpers. Exposed because the operator-side wire layer (kevy-rt’s SCRIPT LOAD / EVALSHA codec) needs to convert between the 20-byte digest used as a cache key and the 40-char ASCII hex Redis uses on the wire. Hand-rolled SHA-1 (RFC 3174 / FIPS 180-1).

Structs§

Bridge
kevy-lua per-shard bridge. One Bridge lives in each shard’s runtime; it owns the per-dialect VM pool, the SHA1 cache, and (P3+) the kevy-side dispatch callback that redis.call invokes.

Enums§

FlushMode
SCRIPT FLUSH mode (Redis 6.2+ semantics).
LuaVersion
Re-export so callers can name the dialect without depending on luna-core directly. Lua dialect the VM emulates. Drives lexer, parser, and runtime feature gating. Lua55 is the primary; the others are compat modes; MacroLua (v1.3 Phase ML) is an additive dialect built on top of the 5.4 base.

Type Aliases§

Reply
A wire-level reply: just the encoded RESP bytes.
ScriptSha1
A SHA1 hash of a script’s source bytes. Used as the EVALSHA cache key. Includes any #!lua version=N shebang in the input, so a 5.1 script and the same script with a 5.3 shebang have distinct SHA1s and never collide in the cache.