Repository navigation
feat(server): add a Server builder with readiness and metrics - #40
Merged
Merged
Conversation
Add a Server builder, Server::new(function, &args).serve(), with Server::ready(future) as its first option; serve becomes a thin wrapper around it and keeps its signature. Options arrive as builder methods with private fields, so adding one never breaks a caller the way the public Args.metrics_address field did in 0.3.0. With ready set, the server listens at once but reports NOT_SERVING for both "" and FunctionRunnerService and answers RunFunction with UNAVAILABLE until the future resolves. Ok flips both to SERVING; an error shuts the server down and serve returns it as Error::NotReady. Without it, the function reports SERVING from the start, as before. Error gains the NotReady variant. Error is not non_exhaustive, so this breaks exhaustive matches on it. The server test helpers move to tests/common so the new tests run in their own binary, apart from the exact metric counts in serve.rs. Fixes #35 Signed-off-by: Jonasz Małecki <jonasz@upbound.io>
Add Server::metrics_registry(registry), the Rust shape of function-sdk-go's WithMetricsRegistry. The function builds a prometheus-client Registry, registers its own series and hands it to the server, which adds its grpc_server_* series at the root and serves the result at /metrics. The four grpc_server_* counter families stay process-wide statics, so the counting layer is unchanged, but they are no longer registered in a static registry: serve registers them into the registry it serves, the function's or an empty one. Without a registry the output is unchanged. prometheus-client becomes part of the public API. The SDK does not re-export it; a function depends on a semver-compatible version itself, as the metrics_registry doc states. Fixes #36 Signed-off-by: Jonasz Małecki <jonasz@upbound.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the
Serverbuilder withreadyfrom #35 andmetrics_registryfrom #36, withservekeeping its signature. One addition to the issue: a readiness future that panics also stops the server withError::NotReady, instead of leaving it NOT_SERVING forever.Fixes #35
Fixes #36