Skip to content

feat(sdk): hand health reporter to the caller - #2

Closed
jonasz-lasut wants to merge 1 commit into
mainfrom
feat/serve-service-health
Closed

jonasz-lasut wants to merge 1 commit into
mainfrom
feat/serve-service-health

Conversation

@jonasz-lasut

Copy link
Copy Markdown
Collaborator

What

Adds serve_service_with_health, which returns the gRPC HealthReporter alongside the server future instead of reporting the service as serving up front. The service starts as NOT_SERVING; the caller flips it with set_serving when ready. serve_service (#1) becomes a delegate that flips to serving immediately, so existing behavior is unchanged. HealthReporter is re-exported so callers do not need a direct tonic-health dependency.

Why

A function that does start-up work - warming module caches, compiling wasm - should listen immediately and let probes read NOT_SERVING while it warms: a closed port reads as a crashed process (connection refused) and can restart-loop the pod, while NOT_SERVING on an open port is exactly the state gRPC health exists to express. Requests arriving mid-warm-up are served (cold) regardless of health status - health is what probes read, not a gate. This is the readiness shape function-wasm's Go runtime has; the handle lets the Rust runtime match it.

Notes

  • The server future is returned rather than awaited so the caller holds the reporter before anything listens; + use<S> precise capturing keeps the future 'static (it borrows nothing from Args), so it can be tokio::spawned.
  • The integration test asserts the full sequence: NOT_SERVING at start, RunFunction answered while not serving, SERVING after the flip.

Slated for 0.3.0 together with #1.

serve_service_with_health returns the gRPC health reporter next to
the server future, with the service starting as NOT SERVING; the
caller flips it when ready. A function warming caches at start-up
can serve requests immediately (health is what probes read, not a
gate) while probes correctly see it as not ready - a closed port
would read as a crashed process instead. serve_service delegates,
reporting serving up front as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jonasz-lasut

Copy link
Copy Markdown
Collaborator Author

Superseded by the ServerBuilder rework in #3: a builder composes custom codec, caller-owned health and extra services in one chain instead of accumulating free functions. The health-reporter semantics (NOT_SERVING start, requests served regardless, caller flips) carry over as ServerBuilder::health_reporter.

@jonasz-lasut
jonasz-lasut deleted the feat/serve-service-health branch August 25, 2026 22:07
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