pub struct Server { /* private fields */ }Expand description
A Seiva service with opt-in observability (ADR 0027).
serve is the zero-config path; this builder adds the exporters a service
opts into, wired only here at the composition root so the default build
links none. A Server with neither hook set behaves exactly like serve:
today’s JSON logs, no exporter.
with_metrics(featuremetrics) serves a Prometheus/metricsscrape surface on a separate bind — an admin port, off the public API surface and exempt from auth/rate-limiting like the health probes. The library crates already record against themetricsfacade (seiva_http::track_metrics); this installs the recorder that gives those records a backend.with_tracing(featuretracing-otlp) installs the OpenTelemetry OTLP span exporter and the W3C trace-context propagator.
§Example
use seiva_server::{Server, ServerConfig};
let config = ServerConfig::from_process_env()?;
Server::new(config)
.with_metrics("127.0.0.1:9090".parse()?)
.serve(async {})
.await?;Implementations§
Source§impl Server
impl Server
Sourcepub fn new(config: ServerConfig) -> Self
pub fn new(config: ServerConfig) -> Self
A server over config with no observability exporter opted in (equivalent
to serve until a hook is added).
Sourcepub async fn serve(
self,
shutdown: impl Future<Output = ()> + Send + 'static,
) -> Result<(), ServeError>
pub async fn serve( self, shutdown: impl Future<Output = ()> + Send + 'static, ) -> Result<(), ServeError>
Serves the framework HTTP surface until shutdown resolves, alongside the
opted-in exporters, then drains.
The one shutdown is fanned out to the main server and the (optional)
metrics server, so a single signal stops both. The main server is exactly
serve; the metrics server runs on its own task and bind.
§Errors
Returns ServeError::Observability if an opted-in exporter cannot be
installed, or the same errors as serve for the main server.