Skip to content

Let services and handlers declare themselves non-preemptable - #324

Open
StephanEwen wants to merge 1 commit into
mainfrom
preemptable-flag
Open

StephanEwen wants to merge 1 commit into
mainfrom
preemptable-flag

Conversation

@StephanEwen

Copy link
Copy Markdown
Contributor

Adds a preemptable option on services and handlers (default true, the handler overrides the service), sent in the endpoint manifest under discovery protocol V6. When false, the runtime never eagerly suspends invocations of that handler to free concurrency capacity. Below V6 the field is dropped instead of failing discovery, since older runtimes never preempt.

Requires restatedev/restate#6026 (discovery protocol V6), which is split out of restatedev/restate#5931.

🤖 Generated with Claude Code

Adds a `preemptable` option on services and handlers (default true, the
handler setting overrides the service one), sent in the endpoint manifest
under service discovery protocol V6. When false, the runtime never eagerly
suspends invocations of the handler to free concurrency capacity; they still
suspend on the inactivity timeout. For runtimes that negotiate an older
discovery version the field is dropped instead of failing discovery, since
those runtimes never preempt invocations.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. The flag is passed through as-is at both the service and handler level, and the runtime resolves the handler override. Below V6 the field is dropped instead of rejected, which is right because older runtimes never preempt.

Reviewed changes

I reviewed the whole diff: the option plumbing, the manifest emission, the V6 negotiation and the new tests.

  • Option plumbing: preemptable is added to the Service, VirtualObject and Workflow constructors and to handler(), main() and _add_handler(). It flows through make_handler to Handler.preemptable. SessionObject.handler/view and AgentObject/AgentOptions forward it too, so agent-internal handlers inherit the service value.
  • Manifest: discovery.Service and discovery.Handler carry preemptable. PythonClassEncoder leaves it out when it is None, so the field appears only when explicitly set.
  • Version handling: send_discovery negotiates endpointmanifest.v6+json ahead of v5. compute_discovery_json clears the field for version <= 5. I checked restatedev/restate#6026: V6 only adds this optional bool (default true, the handler overrides the service), so advertising V6 brings no other manifest obligations.
  • Tests: tests/discovery.py covers V6 emission, the handler override and inheritance, and V6/V5 negotiation end to end through send_discovery. These tests and ruff both pass locally.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@github-actions

Copy link
Copy Markdown

Test Results

  8 files  ±0    8 suites  ±0   4m 9s ⏱️ +11s
 71 tests ±0   71 ✅ ±0  0 💤 ±0  0 ❌ ±0 
322 runs  ±0  322 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 6b2e9db. ± Comparison against base commit 570960b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant