Repository navigation
Let services and handlers declare themselves non-preemptable - #665
StephanEwen wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
✅ 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:
ServiceDefinitionandHandlerDefinitionget a nullablepreemptablefield. It is threaded through every constructor,with*copy,Configurator,equalsandhashCode. - Kotlin: New
preemptableextension properties on both configurators, matching theingressPrivatepattern. - Spring Boot: The global default, per-component and per-handler properties are wired in
RestateEndpointConfiguration. The old all-args constructors are kept and delegate withnull. The no-arg constructors are unchanged, so JavaBean binding still works. - Discovery negotiation:
V5andV6are added, withMAX = V6and V5 excluded from negotiation.serializeManifestnow builds the excluded fields cumulatively, so each new version is oneifblock. - Schema/proto: The vendored
endpoint_manifest_schema.jsongetspreemptableon services and handlers.discovery.protogets 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
preemptableis 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.
claude-opus-5-5 | 𝕏
Test Results 8 files ±0 8 suites ±0 4m 1s ⏱️ -2s Results for commit 91d7438. ± Comparison against base commit 39c4ffa. This pull request removes 1 test.♻️ This comment has been updated with latest results. |

Adds a
preemptableoption 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