Skip to content

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

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. V5 is declared only because the version enum is positional; it is not accepted, so runtimes that offer at most V5 still get V4.

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. preemptable is an optional manifest field that is safe to drop for runtimes older than V6, because those runtimes never preempt. Filtering it out at serialization time, instead of rejecting it in EndpointManifest.manifest like the V2–V4 fields, is the right call. Skipping V5 through isSupported() keeps runtimes that offer at most V5 on V4. The SDK never advertises eagerStateKeysWhitelist, which it doesn't implement.

Reviewed changes: I reviewed the full single-commit diff across the public API, Kotlin, Spring Boot, discovery negotiation and serialization, the schema, and tests.

  • Definition API: ServiceDefinition and HandlerDefinition get a nullable preemptable field. It is threaded through every constructor, with* copy, Configurator, equals and hashCode.
  • Kotlin: New preemptable extension properties on both configurators, matching the ingressPrivate pattern.
  • Spring Boot: The global default, per-component and per-handler properties are wired in RestateEndpointConfiguration. The old all-args constructors are kept and delegate with null. The no-arg constructors are unchanged, so JavaBean binding still works.
  • Discovery negotiation: V5 and V6 are added, with MAX = V6 and V5 excluded from negotiation. serializeManifest now builds the excluded fields cumulatively, so each new version is one if block.
  • Schema/proto: The vendored endpoint_manifest_schema.json gets preemptable on services and handlers. discovery.proto gets the V5 and V6 entries, which match upstream's V5 comment.
  • Tests: New tests cover negotiation (V4/V5/V6 → V6, V4/V5 → V4) and check that preemptable is sent at V6 only where it is set, and dropped at V3 and V4.

I couldn't run the tests locally: the build needs a Java 21 JVM to load the gradle-plugin-jextract plugin, and this runner only has Java 17. CI checks were still pending when this review was submitted.

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

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  8 files  ±0    8 suites  ±0   4m 1s ⏱️ -2s
 59 tests  - 1   59 ✅  - 1  0 💤 ±0  0 ❌ ±0 
266 runs   - 1  266 ✅  - 1  0 💤 ±0  0 ❌ ±0 

Results for commit 91d7438. ± Comparison against base commit 39c4ffa.

This pull request removes 1 test.
dev.restate.sdktesting.tests.ServiceToServiceScopeConcurrency ‑ scopeAndLimitKeyArePropagatedOnServiceToServiceCalls(URI, ContainerHandle, Client)

♻️ This comment has been updated with latest results.

This branch has not been deployed

No deployments
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