-
Couldn't load subscription status.
- Fork 643
Phoebe/procedures #3390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gefjon
wants to merge
32
commits into
master
Choose a base branch
from
phoebe/procedures
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Phoebe/procedures #3390
Conversation
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
Discussion in other forums has yielded a better design, where procedure code can programmatically register `on_abort` handlers at runtime.
I even called some myself to try it!
No implementation; linking will fail.
At this stage, changes are not integrated, so build is broken.
But these are never supposed to block, so use a custom "executor" which only calls `poll` once.
This reverts commit b26d447. These changes are now in a separate branch, `phoebe/skippable-tests`.
Co-authored-by: Mazdak Farrokhzad <[email protected]> Co-authored-by: joshua-spacetime <[email protected]> Signed-off-by: Phoebe Goldman <[email protected]>
…etimeDB into phoebe/wasmtime-async
So that we can determine whether we should be running this on the database core or not
And fix typo that mis-categorized `Module::Js` as `ModuleType::Wasm`.
It's not used in private either, and no one knew what it was for, so I'm cutting it.
and resolve just a whole boatload of merge conflicts
I successfully called this: ```bash [phoebe@phoebe-desktop:~/clockworklabs/SpacetimeDB/modules/module-test]$ curl -H "Content-Type:application/json" -X POST -d '[]' http://localhost:3000/v1/database/module-test/procedure/this_procedure_sleeps "Started at 2025-10-02T14:46:22.288936+00:00, requested to sleep until 2025-10-02T14:46:23.288936+00:00, woke at 2025-10-02T14:46:23.290299+00:00" ```
Prior to this commit, when shutting down SpacetimeDB-standalone via C-c / SIGINT, the process would print a panic message and backtrace (if enabled) due to dropping nested Tokio runtimes. This commit avoids doing so in SpacetimeDB-standalone, and adds a note to `JobCores` instructing how to avoid it in other uses.
2 tasks
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 24, 2025
# Description of Changes
This commit adds a macro attribute `#[procedure]` which applies to
functions, and various in-WASM machinery for defining, calling and
running procedures.
A simple example of a procedure, included in `modules/module-test`:
```rust
fn sleep_one_second(ctx: &mut ProcedureContext) {
let prev_time = ctx.timestamp;
let target = prev_time + Duration::from_secs(1);
ctx.sleep_until(target);
let new_time = ctx.timestamp;
let actual_delta = new_time.duration_since(prev_time).unwrap();
log::info!("Slept from {prev_time} to {new_time}, a total of {actual_delta:?}");
}
```
We intend eventually to make procedures be `async` functions (with the
trivial `now_or_never` executor from `future-util`), but I found that
making the types work for this was giving me a lot of trouble, and
decided to put it off in the interest of unblocking more parallelizable
work.
Host-side infrastructure for executing procedures is not included in
this commit. I have a prototype working, but cleaning it up for review
and merge will come a bit later.
One item of complexity in this PR is enabling scheduled tables to
specify either reducers or procedures, while still providing
compile-time diagnostics for ill-typed scheduled functions (as opposed
to publish-time). I had to rewrite the previous
`schedule_reducer_typecheck` into a more complex `schedule_typecheck`
with a trait `ExportFunctionForScheduledTable`, which takes a "tacit
trait parameter" encoding reducer-ness or procedure-ness, as described
in https://willcrichton.net/notes/defeating-coherence-rust/ .
The trait name `ExportFunctionForScheduledTable` is user-facing in the
sense that it will appear in compiler diagnostics in ill-typed modules.
As such, I am open to bikeshedding.
# API and ABI breaking changes
Adds a new user-facing API, which we intend to change before releasing.
# Expected complexity level and risk
2? Mostly pretty mechanical changes to macros and bindings.
# Testing
- [x] Added a procedure definition to `module-test`, saw that it
typechecks.
- [x] Executed same procedure definition using #3390 , the prototype
implementation this PR draws from.
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.
Description of Changes
API and ABI breaking changes
Expected complexity level and risk
Testing