Skip to content

Feat/db interface all - #95

Open
godronus wants to merge 16 commits into
mainfrom
feat/db-interface-all
Open

godronus wants to merge 16 commits into
mainfrom
feat/db-interface-all

Conversation

@godronus

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings October 30, 2026 09:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 json feature.
  • 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

Comment thread Cargo.toml
default = ["proxywasm"]
proxywasm = []
json = ["serde_json"]
json = ["serde_json", "serde"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 '{}'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4f07841: Meta.plan is optional, so rows with the default {} decode (and serialise back as {}, as in the JS example).

Comment thread src/db.rs
Comment on lines +152 to +153
/// 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/lib.rs
}

/// Customer-owned databases bound to the app by name (`gcore:db`).
pub mod db;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants