-
Notifications
You must be signed in to change notification settings - Fork 645
Add Rust client SDK bindings for calling procedures #3532
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
Open
gefjon
wants to merge
8
commits into
master
Choose a base branch
from
phoebe/procedure/rust-sdk
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.
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
This commit adds support to the Rust client SDK for calling procedures. Similar to reducers, each `DbContext` implementor has a `pub procedures: RemoteProcedures` field, with methods provided by extension traits for each procedure. Unlike reducers, the provided methods are invoke and invoke-then. Invoke-then takes a `FnOnce` callback to run when the SDK is notified of the procedure's termination status, while invoke ignores that notification. No mechanism is provided for observing procedures invoked by other clients. Procedure callbacks are implemented by storing a map from `request_id` to `ProcedureCallback`, with the callback closure internally knowing how to deserialize the return value. It's mildly unfortunate to deserialize within the callback instead of on the preprocess background task, but it saves significant complexity. This commit also adds a new sdk-test module, `sdk-test-procedures`, and a new Rust test client, `procedure-client`. Together, these are used in two tests of invoking and observing procedures. I've left TODOs for other tests that we should write as we implement additional procedure features.
|
Closes #3513 |
…SpacetimeDB into phoebe/procedure/rust-sdk
This was referenced Oct 30, 2025
We're generating empty files for C# and TypeScript bindings for now, which still appear in the snaps
Centril
approved these changes
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some minor things.
cloutiertyler
approved these changes
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving my code owned files.
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
This commit adds support to the Rust client SDK for calling procedures.
Similar to reducers, each
DbContextimplementor has apub procedures: RemoteProceduresfield, with methods provided by extension traits for each procedure.Unlike reducers, the provided methods are invoke and invoke-then. Invoke-then takes a
FnOncecallback to runwhen the SDK is notified of the procedure's termination status, while invoke ignores that notification.
No mechanism is provided for observing procedures invoked by other clients.
Procedure callbacks are implemented by storing a map from
request_idtoProcedureCallback, with the callback closure internally knowing how to deserialize the return value. It's mildly unfortunate to deserialize within the callback instead of on the preprocess background task, but it saves significant complexity.This commit also adds a new sdk-test module,
sdk-test-procedures, and a new Rust test client,procedure-client.Together, these are used in two tests of invoking and observing procedures. I've left TODOs for other tests that we should write as we implement additional procedure features.
I also had to fix a few minor bugs in the Rust codegen which were not strictly related to procedures: we previously assumed that the sets of reducers and of tables were non-empty, which led to wonky invalid codegen on modules which did not define any reducers or which did not define any tables.
API and ABI breaking changes
Breaks the internal interface between the Rust client SDK and codegen, so users will have to re-run
spacetime generate.Expected complexity level and risk
2-ish? Pretty simple change to the Rust SDK overall.
Testing