feat: signals API and id-backed InvocationHandle#120
Merged
Conversation
Add signals: named, invocation-scoped durable promises. A handler awaits a signal by name via `ctx.signal::<T>(name)` (a DurableFuture, usable in select!); another handler completes it via `ctx.invocation_handle(id).signal(name).resolve(v)` / `.reject(e)`. Built on the shared-core create_signal_handle/sys_complete_signal syscalls. Redesign InvocationHandle from a trait into an id-backed struct with a synchronous invocation_id() and cancel(), plus attach() (sys_attach_invocation) and signal(). send()/send_after() now return an awaitable SendHandle (the send is eager, so fire-and-forget `.send();` still works). CallFuture gains invocation_handle(&self) and keeps a deprecated invocation_id(). Wire signals into the test-services (createSignal command, resolveSignal/rejectSignal handlers) and add examples/signals.rs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Adds signals to the Rust SDK — named, one-shot durable promises scoped to an invocation, matching the feature already shipped in the TypeScript, Python, and Go SDKs. Built on the
create_signal_handle/sys_complete_signal/sys_attach_invocationsyscalls that were already present (unused) inrestate-sdk-shared-core 0.10.0, so no dependency bump.A handler awaits a signal by name; any other handler completes it by targeting the awaiter's invocation id + signal name — i.e. "awakeables addressed by
(invocation_id, name)", with no opaque token to exfiltrate.InvocationHandleredesign (breaking)To make the signal send-side ergonomic (and generally cleaner),
InvocationHandlebecomes an id-backed struct with synchronous accessors:invocation_id() -> &str(wasasync -> Result<String, _>)cancel()— sync fire-and-forget (was async)attach::<T>()— new, awaits the invocation's output (sys_attach_invocation)signal(name)— new, returns aSignalHandlewithresolve/rejectConsequently:
send()/send_after()now return an awaitableSendHandle(impl IntoFuture→InvocationHandle). The send is issued eagerly, so bareclient.foo().send();still fire-and-forgets.IntoFuture(rather than a bareimpl Future) keeps fire-and-forget free of the must-use lint and keeps the eager send/lazy-id split clean.call()still awaits to the response and gainsinvocation_handle(&self)(takes&self, does not consume the future); it retains a#[deprecated]invocation_id()to soften the break.CallFuturedrops itsInvocationHandlesupertrait.Test-services / e2e
createSignalcommand added toVirtualObjectCommandInterpreter.resolveSignal/rejectSignalhandlers added toTestUtilsService.Matches the contract implemented in the other SDKs so the shared e2e suite exercises the flows.
Example
New
examples/signals.rs(await / resolve / reject).Verification
cargo build --workspace --all-features --all-targets✅cargo clippy --workspace --all-features --all-targets -- -D warnings✅# Signalsdoc examples compile)🤖 Generated with Claude Code