Commit Graph

40 Commits

Author SHA1 Message Date
Noa de142d4af9 HTTP followup: remove http dep from spacetimedb_lib (#3719)
# Description of Changes

Follow up to #3684. Moves `Error` and `Timeout` out of lib, so that we
don't have to implement `SpacetimeType` for them, and then removes the
http dependency altogether, so that `lib` can be leaner. I also got rid
of the separate `HttpValue` type, since it only really exists to mirror
the `http` crate and typescript won't make use of it.

# Expected complexity level and risk

1

# Testing

n/a - just code movement.
2025-11-21 06:01:21 +00:00
Phoebe Goldman 7df8719b61 Add procedure HTTP request API for WASM modules and the Rust module bindings library (#3684)
# Description of Changes

Closes #3517 .

With this PR, procedures (at least, those defined in Rust modules) can
perform HTTP requests! This is performed through a new field on the
`ProcedureContext`, `http: HttpClient`, which has a method `send` for
sending an `http::Request`, as well as a convenience wrapper `get`.

Internally, these methods hit the `procedure_http_request` ABI call /
host function, which uses reqwest to perform an HTTP request. The
request is run with a user-configurable timeout which defaults and is
clamped to 500 ms.
Rather than exposing the HTTP stream to modules, we download the entire
response body immediately, within the same timeout.

I've added an example usage of `get` to `module-test` which performs a
request against `localhost:3000` to read its own schema/moduledef.

This PR also makes all procedure-related definitions in the Rust module
bindings library `#[cfg(feature = "unstable")]`, as per #3644 . The
rename of the `/v1/database/:name/procedure/:name` route is not included
in this PR, so this does not close #3644 .

Left as TODOs are:
- Metrics for recording request and response size.
- Improving performance by stashing a long-lived `reqwest::Client`
someplace.
  Currently we build a new `Client` for each request.
- Improving performance (possibly) by passing the request-future to the
global tokio executor
  rather than running it on the single-threaded database executor.

# API and ABI breaking changes

Adds new APIs, which are marked as unstable. Adds a new ABI, which is
not unstable in any meaningful way (we can't really do that). Marks
unreleased APIs as unstable. Does not affect any pre-existing
already-released APIs or ABIs.

# Expected complexity level and risk

3 or so: networking is scary, and even though we impose a timeout which
prevents these connections from being truly long-lived, they're still
potentially long-lived on the scale of Tokio futures. It's possible that
running them on the database core is problematic in some way, and so
what I've left as a performance TODO could actually be a
concurrency-correctness issue.

# Testing

- [x] Manually wrote and executed some procedures which make HTTP
requests.
- [x] Added two automated tests to the `sdk-test` suite,
`procedure::http_ok` and `procedure::http_err`, which make successful
and failing requests respectively, then return its result. A client then
makes some assertions about the result.

---------

Co-authored-by: Noa <coolreader18@gmail.com>
2025-11-20 20:47:35 +00:00
Noa 742303ca49 Bump rust-toolchain to rust 1.88 (#2749)
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-07-15 17:39:41 +00:00
Mazdak Farrokhzad 1166d68e65 Extract spacetimedb-memory-usage & Nix bindings dep on spacetimedb-data-structures (#2919) 2025-07-04 12:54:00 +00:00
Zeke Foppa 118e59de14 CI - Do some basic checks that crates are publishable (#2660)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-23 17:08:43 +00:00
Noa 483a9488e2 Update rand (#2568) 2025-04-11 17:39:41 +00:00
joshua-spacetime 9a2b30f321 Support RFC 3339 timestamp values in sql (#2242) 2025-03-06 21:18:20 +00:00
Noa cf6ac18eaf Lookup lifecycle reducers by lifecycle flag, not by name (#2132) 2025-01-17 23:21:52 +00:00
Jeffrey Dallatezza 942fd8be83 Handle JWT tokens with oidc providers (#1882) 2024-10-23 05:46:53 +00:00
Tyler Cloutier 83fc5c33d4 The banishment of Address (#1880)
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2024-10-23 01:56:20 +00:00
Noa dd699c437a Make our sats<->serde translation compatible with RON (#1738) 2024-09-27 19:24:11 +00:00
james gilles 1b48555a42 Add lib::db::{column_ordering, raw_def::v9} (#1542)
Signed-off-by: james gilles <jameshgilles@gmail.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-08-07 19:13:18 +00:00
james gilles f81f2a7492 Move db module from spacetimedb_sats to spacetimedb_lib (#1479) 2024-07-17 20:59:44 +00:00
Noa a54399495d Prune bindings deps (#1290) 2024-06-07 20:36:33 +00:00
Noa abdaf88563 Move lib::{name,recovery} to client-api-messages (#570) 2024-04-10 20:24:05 +00:00
joshua-spacetime 5203b01fa6 refactor(1058): Remove feature flag for disabling metrics (#1059)
Closes #1058.
2024-04-09 20:25:32 +00:00
Noa 7d3bdc308b Prune deps from bindings dependency tree (#1014) 2024-04-03 01:54:36 +00:00
John Detter 79fd5ad75e Fix publish issues 0.8.2 (#853)
* Fix some issues related to publishing 0.8.2

* Added phoebe's fix

* Reverting file

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-02-15 23:29:37 +00:00
Noa 37658aae7e Add rust-version to Cargo.toml (#802)
* Add rust-version to Cargo.toml

* Use workspace inheritance to make bumping the spacetime version easier
2024-02-07 20:02:05 +00:00
John Detter 8524d244f3 Version upgrade to 0.8.1 (#729)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-01-18 18:16:58 +00:00
joshua-spacetime 09b2d0f033 refactor(metrics): Move table size metric into lib (#636)
Query optimization will soon need this metric.
Therefore it must be moved out of core and into lib.
Eventually we might want to move all metrics into lib.
2023-12-08 14:20:56 -08:00
joshua-spacetime c265ed195f refactor(metrics): Move metric builder macros into their own crate 2023-12-05 10:26:41 -08:00
John Detter 79ff6dffc6 Version upgrade to 0.8.0 (#622)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-04 13:19:25 -06:00
Mario Montoya b3ccc13dab Refactoring IDs for system objects (#439)
* Refactoring IDs for system objects

* fixup

* Fix stray constraints text on refactor

* Fix conflict

* Merge

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-11-15 10:21:20 -05:00
John Detter dff23de939 Version upgrade to v0.7.3 (#536)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-11-07 21:55:14 -06:00
Kim Altintop 0a4c2f16b0 lib: Provide Arbitrary impls for Hash and DataKey
Allows to remove custom strategies for the commit log types (in core),
and may become useful for future property testing efforts.
2023-11-06 10:50:05 +01:00
John Detter b35e184051 Version Upgrade to v0.7.2-beta (#498)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-30 16:53:06 -05:00
Mazdak Farrokhzad cba518d90e Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*) (#408)
* Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*)

* Addressing some PR comments

---------

Co-authored-by: Mario Alejandro Montoya Cortés <mamcx@elmalabarista.com>
2023-10-19 11:18:50 -05:00
John Detter 5864bfa8d7 Version upgrade: v0.7.1-beta (#441)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-17 16:57:36 -07:00
John Detter de43e96b11 Version Upgrade to 0.7.0 (#355)
* Saving because I'm testing writing files

* New upgrade program working quite well

* Update license file as well

* Tool seems good to go

* Cargo check is passing, new upgrade-version is ready, old version
removed

* Updating lock file is required for CI to pass

* main.rs clippy lints

* More sensible default

* Version upgrade to 0.7.0 via new version-upgrade util

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-10-03 22:27:11 +00:00
Mazdak Farrokhzad 12a7e7f572 use derive_more::From (#281) 2023-09-13 11:40:23 +00:00
joshua-spacetime 33e7d07947 chore: add more tracing to vm (#246) 2023-08-30 07:01:19 -07:00
Ingvar Stepanyan cc632ef9f6 Make ColumnIndexAttribute bitflags in the ABI (#212)
As we're adding more variants, it's getting harder to keep track of the "A implies B" relationships between enum variants and to correctly do checks like "is this column autoinc" in different places.

Using bitflags makes expressing those relationships more natural and checking simpler - e.g. you can just do `contains(AUTO_INC)` as a single bit operation instead of having to remember and list all possible variants that imply autoinc, especially if we're going to add more flags in the future.

Initially I was going to make this change just in C# module generator and convert between ABI enum and bitflags over there, but it seems better to do this at ABI level so it simplifies Rust handling as well.
2023-08-29 11:35:57 -05:00
John Detter 116bdee090 Version upgrade to 0.6.1 (#180)
* Version upgrade to 0.6.1

* Upgrade version used by CLI

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-12 08:56:28 -07:00
Mario Montoya 80a0a29704 Move cargo deps to the workspace (#172)
* Moving deps to workspace

* Merge
2023-08-11 15:24:31 -07:00
Tyler Cloutier 3e0caff415 Updated version to 0.6.0 2023-08-03 01:39:03 +02:00
John Detter 0f63e70694 spacetime start 2 (#125)
* spacetime start

README revert

Reverted stuff that shouldn't have changed

* Build fix

* Cargo fmt

* Cargo clippy

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-02 11:21:49 -05:00
John Detter 41dc128533 Upgrade Version to 0.5.0 (#47)
* Committing version upgrade script

* Fixes to the upgrade script

* Upgrade version to 0.5.0

* Update Cargo.toml

No longer optional

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Fixed small issue in the version upgrade script

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
Tyler Cloutier 0b6cddca13 test (#1)
* test

* Fixed CI

* Fixed tests

* Fixed formatting

* Fixed test error by removing chrono default features

* Rename smoketests CI thing

* Hopefully fix the testing issue

* Fix typos

* Fixed install git-hooks

* Fixed formatting

* Fixed compile error

* fixed testing issues
2023-08-01 23:17:02 +02:00
Tyler Cloutier 44df6c6e7d Initial commit 2023-08-01 23:16:37 +02:00