Skip to main content

solti_discover/
lib.rs

1//! # solti-discover - agent heartbeat.
2//!
3//! Periodic sync task that registers an agent with the control plane and reports liveness and platform telemetry.
4//!
5//! | feature | transport         | protocol                      |
6//! |---------|-------------------|-------------------------------|
7//! | `grpc`  | tonic gRPC client | `proto/v1/sync.proto`         |
8//! | `http`  | reqwest HTTP/JSON | `POST /api/v1/discovery/sync` |
9//!
10//! ## Quick start
11//!
12//! ```text
13//! let cfg = DiscoverConfig::builder(/* ... */).build()?;
14//! let (task, spec) = solti_discover::sync(cfg)?;
15//! supervisor.submit_with_task(task, &spec).await?;
16//! ```
17//!
18//! ## Also
19//!
20//! - [`DiscoverConfig`] / [`DiscoverConfigBuilder`] identity, endpoint, transport, timeouts, capabilities.
21//! - [`DiscoverError`] config, transport, parse, and rejection failures.
22//! - [`sync`] factory returning `Result<(TaskRef, TaskSpec), DiscoverError>`.
23
24mod errors;
25pub use errors::DiscoverError;
26
27mod metrics;
28pub use metrics::{
29    DiscoverMetricsBackend, DiscoverMetricsHandle, FAIL_AUTH, FAIL_CONNECT, FAIL_OTHER, FAIL_PARSE,
30    FAIL_REJECTED_CLIENT, FAIL_REJECTED_SERVER, FAIL_TIMEOUT, NoOpDiscoverMetrics, OUTCOME_FAILURE,
31    OUTCOME_SUCCESS, noop_discover_metrics,
32};
33
34#[cfg(any(feature = "grpc", feature = "http"))]
35mod config;
36#[cfg(any(feature = "grpc", feature = "http"))]
37pub use config::{
38    DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, DiscoverConfig, DiscoverConfigBuilder,
39    DiscoveryTransport,
40};
41
42#[cfg(any(feature = "grpc", feature = "http"))]
43mod tasks;
44#[cfg(any(feature = "grpc", feature = "http"))]
45pub use tasks::sync;
46
47#[cfg(any(feature = "grpc", feature = "http"))]
48pub(crate) mod proto {
49    include!(concat!(env!("OUT_DIR"), "/solti.discover.v1.rs"));
50
51    #[cfg(feature = "http")]
52    include!(concat!(env!("OUT_DIR"), "/solti.discover.v1.serde.rs"));
53}
54
55#[cfg(any(feature = "grpc", feature = "http"))]
56pub use proto::{SyncRequest, SyncResponse};