spike: hiqlite-in-Encore.ts NAPI feasibility (Shape A PoC + report)#40
Draft
bartekus wants to merge 3 commits into
Draft
spike: hiqlite-in-Encore.ts NAPI feasibility (Shape A PoC + report)#40bartekus wants to merge 3 commits into
bartekus wants to merge 3 commits into
Conversation
…port) Evaluate embedding hiqlite directly into Encore.ts tenant apps as an in-process native capability via napi-rs, rather than a network sidecar. Verdict: neither shape as a near-term build. Shape B (native Encore primitive) is a 4-surface fork of a weekly-moving upstream; Shape A (standalone napi addon) is technically clean and proven buildable but solves a value problem that does not exist yet for tenant apps (a shared cross-replica cache would force StatefulSet Raft clustering that fights Encore's autoscaled-Deployment model). Hold Shape A in reserve. PoC (experiments/hiqlite-native-spike, throwaway): a napi-rs addon linking hiqlite (single-node, cache-only) exposing put/get, called from one Encore.ts endpoint. Confirmed under `encore run` (Q2: hiqlite's tokio coexists with Encore's Rust runtime) and inside an `encore build docker` image (Q4: the native .node bundles and loads). Prebuilt binaries and Rust build output are gitignored; RESULTS.md has the reproduce steps. Report: docs/analysis/hiqlite-napi-feasibility.md
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.
What
Feasibility spike: can
hiqlitebe embedded directly into Encore.ts tenantapps as an in-process native capability via napi-rs (cache / dlock / counters /
listen_notify), rather than a network sidecar? Two shapes were evaluated:
Encore primitive.
This is strategic / forward-looking. There is no live gap (rate-limiting
stays Postgres; there is no Redis in the stack). This branch is a throwaway
spike for review and record, not a feature intended to merge to
mainas-is.Verdict
Neither shape as a near-term build.
4-surface fork (encore-runtime-core + encore-js-runtime + the
encore.devSDKPoC below), but it is a delivery mechanism for a value case that does not exist
yet for tenant apps: a shared cross-replica cache requires StatefulSet Raft
clustering that fights Encore's autoscaled-Deployment model. Absent that, an
in-process map or Postgres wins.
Full analysis (Q1 through Q6, licensing, costs) in
docs/analysis/hiqlite-napi-feasibility.md.PoC (executed, green)
experiments/hiqlite-native-spike/(throwaway): a napi-rs addon linking hiqlite=0.13.2(single-node, cache-only, no SQLite-C) exposingput/get, calledfrom one Encore.ts endpoint.
encore run,put/getround-trips through Encore into napi into hiqlite. hiqlite's tokio (in the
addon's own dylib) coexists with Encore's Rust runtime in one process, no
contention or nested-runtime panic.
encore build dockerbundles + loads the native addon): CONFIRMED.A cross-built Linux
.nodebundled into the image and loaded at runtime; thesame round-trip works in-container.
Real costs (all in native distribution, not runtime coexistence): cross-build the
addon per target yourself; ship a real npm package with per-platform
optionalDependencies(not afile:symlink);bundle_sourceover annpm-workspace root bundles the whole repo (needs a
.dockerignore); theself-host gateway binds
:8080. Details and reproduce steps inexperiments/hiqlite-native-spike/RESULTS.md.Not in this branch
Prebuilt
.nodebinaries, napi-generated loaders, Rusttarget/output, andnode_modulesare gitignored.RESULTS.mdhas the exact commands to regenerateand re-run everything.