Add store support for Spin adapter (KV, config, secret)#253
Open
Add store support for Spin adapter (KV, config, secret)#253
Conversation
added 14 commits
April 24, 2026 20:05
- dispatch() in request.rs now injects ConfigStoreHandle, KvHandle, and SecretHandle into request extensions on every request - SpinSecretStore normalises the lookup key to lowercase so conventional uppercase names (e.g. SMOKE_SECRET) resolve to the correct Spin variable - contract.rs gains store injection smoke tests (config, kv, secret) and wasm32 compile-time trait checks for SpinKvStore and SpinSecretStore
- spin.toml gains key_value_stores = ["default"] binding and variables declarations for greeting and smoke_secret - edgezero.toml adds "spin" to adapters for config, kv, and secrets routes - smoke_test_kv/config/secrets.sh each gain a spin case that builds the WASM binary and starts spin up --listen 127.0.0.1:3000; the config script skips dotted-key checks (Spin variable names cannot contain dots); the secrets script passes SPIN_VARIABLE_SMOKE_SECRET at startup
spin up creates .spin/ (SQLite KV database and component logs) in the adapter directory during local development, mirroring .wrangler/ for CF.
instead of silently truncating; callers now get an explicit signal rather than incomplete pagination results - Correct DEFAULT_MAX_LIST_KEYS, with_max_list_keys, and module-level docs to accurately describe error-return behaviour (not truncation, not "unbounded allocation" guarding) - Add log::debug in SpinSecretStore::get_bytes when store_name is non-empty so callers learn the flat-namespace constraint at runtime - Add comment in config_store contract tests explaining the InMemory backend accepts dotted/uppercase keys that the real Spin backend would reject via InvalidName - Add comment in lib.rs explaining why SpinConfigStore has different feature gating than SpinKvStore and SpinSecretStore
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.
Summary
SpinKvStore,SpinConfigStore, andSpinSecretStoreso Spin handlers can access key-value, configuration, and secret data through the samectx.kv_handle(),ctx.config_store(), andctx.secret_handle()API as every other adapter.spin-adapter-testsCI job, store injection contract tests, and Spin support to all three smoke test scripts.Changes
crates/edgezero-adapter-spin/src/config_store.rsSpinConfigStorebacked byspin_sdk::variables; dual-backend (Spin / in-memory for tests); contract tests via macrocrates/edgezero-adapter-spin/src/key_value_store.rsSpinKvStorebacked byspin_sdk::key_value; in-process prefix filter + pagination; configurablemax_list_keyscap (warn + truncate); TTL silently ignoredcrates/edgezero-adapter-spin/src/secret_store.rsSpinSecretStorebacked byspin_sdk::variables; key normalised to lowercase to match Spin variable naming rulescrates/edgezero-adapter-spin/src/request.rsdispatch()now injectsConfigStoreHandle,KvHandle, andSecretHandleinto every request's extensionscrates/edgezero-adapter-spin/src/lib.rscrates/edgezero-adapter-spin/tests/contract.rsSpinKvStoreandSpinSecretStorecrates/edgezero-core/src/manifest.rs"spin"toSUPPORTED_CONFIG_STORE_ADAPTERScrates/edgezero-core/src/config_store.rsConfigStoretrait doc to listSpinConfigStore.github/workflows/test.ymlspin-adapter-testsjob: native tests + wasm32-wasip1 compilation checkexamples/app-demo/crates/app-demo-adapter-spin/spin.tomlkey_value_stores = ["default"]binding and variable declarations forgreetingandsmoke_secretexamples/app-demo/edgezero.toml"spin"toadaptersfor config, KV, and secrets routesscripts/smoke_test_kv.shspincasescripts/smoke_test_config.shspincase; skips dotted-key checks (Spin variable names cannot contain dots)scripts/smoke_test_secrets.shspincase; passes secret value viaSPIN_VARIABLE_SMOKE_SECRETat startup.gitignore.spin/(runtime SQLite KV database and component logs)Closes
Closes #73
Closes #74
Test plan
cargo test --workspace --all-targetscargo clippy --workspace --all-targets --all-features -- -D warningscargo check --workspace --all-targets --features "fastly cloudflare spin"cargo check -p edgezero-adapter-spin --target wasm32-wasip1 --features spin./scripts/smoke_test_kv.sh spin./scripts/smoke_test_config.sh spin./scripts/smoke_test_secrets.sh spinChecklist
{id}syntax (not:id)edgezero_core(nothttpcrate)