Repository navigation
Conversation
…served for async)
There was a problem hiding this comment.
🟡 Changes recommended
The schema’s default metadata omits the required plan field, causing otherwise valid inserts to create rows that make GET / fail with a decoding error and HTTP 500.
4 open issues
What changed in this PR
Adds named database bindings to the FastEdge Rust SDK, exposing synchronous PostgreSQL and writable Database KV APIs while keeping connection details with the host.
Changes:
- Adds database bindings, SQL parameter helpers, and typed row decoding behind the
jsonfeature. - Adds async HTTP examples for SQL queries and KV-backed rate limiting.
- Updates dependencies and records database integration decisions.
| File | Description |
|---|---|
src/lib.rs |
Generates database bindings and exports db. |
src/db.rs |
Exposes SQL/KV APIs and SQL conversion helpers. |
examples/README.md |
Lists both database examples. |
examples/http/wasi/db_sql/src/lib.rs |
Demonstrates typed SQL queries through HTTP. |
examples/http/wasi/db_sql/schema.sql |
Defines and seeds the example users table. |
examples/http/wasi/db_sql/README.md |
Documents SQL setup, usage, and errors. |
examples/http/wasi/db_sql/Cargo.toml |
Configures the SQL example and JSON support. |
examples/http/wasi/db_sql/Cargo.lock |
Locks SQL example dependencies. |
examples/http/wasi/db_kv/src/lib.rs |
Demonstrates batched rate limiting and visit counting. |
examples/http/wasi/db_kv/README.md |
Documents KV setup, usage, and errors. |
examples/http/wasi/db_kv/Cargo.toml |
Configures the KV example dependencies. |
examples/http/wasi/db_kv/Cargo.lock |
Locks KV example dependencies. |
context/CHANGELOG.md |
Records database integration decisions and follow-ups. |
Cargo.toml |
Adds optional Serde support to the json feature. |
Cargo.lock |
Records the SDK’s added Serde dependency. |
Review effort: Balanced
| default = ["proxywasm"] | ||
| proxywasm = [] | ||
| json = ["serde_json"] | ||
| json = ["serde_json", "serde"] |
There was a problem hiding this comment.
No change: versions are bumped in a separate chore: bump version commit at release time, as for 0.4.x. This one waits until the engine with gcore:db is on every edge.
| email text not null unique, | ||
| nickname text, | ||
| created timestamptz not null default now(), | ||
| meta jsonb not null default '{}' |
There was a problem hiding this comment.
Fixed in 4f07841: Meta.plan is optional, so rows with the default {} decode (and serialise back as {}, as in the JS example).
| /// Within one request, reads see the request's own writes. Other requests may see a write only | ||
| /// after it has replicated (eventually, for a database with read replicas in other regions). |
There was a problem hiding this comment.
No change: the wit submodule on this branch is at FastEdge-wit eed3ccd, which replaced the strong-consistency wording with read-your-writes within a request; the doc matches it.
| } | ||
|
|
||
| /// Customer-owned databases bound to the app by name (`gcore:db`). | ||
| pub mod db; |
There was a problem hiding this comment.
Deferred: consumer docs will be regenerated when the db API ships, so they don't advertise an API that edges don't support yet.
Meta.plan was required, so a row inserted with only id and email (meta defaults to '{}')
made GET / fail with a decode error. plan is optional and still serialises as {}, matching
the JS example's response.
wit submodule -> FastEdge-wit e41118a. Same API; example db_sql renamed to db_postgres.
…the WIT wit → FastEdge-wit a23194c. Column.type_name replaces type_oid; example db_sql_postgres (named after its dialect). Secret FASTEDGE_DB_SQL_<name>.
Re-exports the sql API under the PostgreSQL name, with SQLSTATE constants (from PostgreSQL's errcodes.txt) and an SqlState helper for Error and QueryAsError. db_sql_postgres uses it.
…es in postgres docs


No description provided.