restate icon indicating copy to clipboard operation
restate copied to clipboard

cancel from Context API

Open slinkydeveloper opened this issue 1 year ago • 2 comments

Expose the ability to do a one way call from the Context, then cancel/kill it from context too.

slinkydeveloper avatar Jul 03 '24 20:07 slinkydeveloper

Temporary workaround: if a workflows' own invocationId is exposed in the context (its already in ContextImpl, just needs to be made public) then workflows can expose a cancel handler which cancels itself using their invocationId and #412. External services can cancel it using the handler (ctx.workflowSendClient(Foo, key).cancel()).

I'm doing this for now by bypassing typescript's fake private fields and just grabbing ctx.stateMachine.invocation.debugId With a bit of work you can make this work for services too, by making service calls self-register in some virtual object. Wouldn't recommend it.

nythrox avatar Jul 23 '24 06:07 nythrox

Train of PRs:

  • https://github.com/restatedev/service-protocol/pull/96
  • https://github.com/restatedev/restate/pull/1967
  • https://github.com/restatedev/sdk-shared-core/pull/10
  • https://github.com/restatedev/sdk-rust/pull/27
  • https://github.com/restatedev/sdk-test-suite/pull/11

slinkydeveloper avatar Sep 18 '24 13:09 slinkydeveloper

Done in Protocol V4

slinkydeveloper avatar Feb 19 '25 08:02 slinkydeveloper

Is there now a way to do this from the SDK? I can't find it in the Rust SDK, at the very least.

musjj avatar Feb 20 '25 11:02 musjj

This is not available in any SDK yet, this was the server part of the feature. In Rust SDK there is an open PR https://github.com/restatedev/sdk-rust/pull/27 but I need to finish this one yet.

slinkydeveloper avatar Feb 20 '25 13:02 slinkydeveloper