MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / new

Method new

nodedb/src/control/trace_export.rs:63–78  ·  view source on GitHub ↗

Construct an exporter that pushes to `endpoint` (e.g. `http://collector:4318`). Fails if the underlying `reqwest::Client` cannot be constructed. An empty endpoint is rejected — use [`disabled`](Self::disabled) instead so the intent stays explicit.

(
        endpoint: impl Into<String>,
        timeout: Duration,
    )

Source from the content-addressed store, hash-verified

61 /// rejected — use [`disabled`](Self::disabled) instead so the
62 /// intent stays explicit.
63 pub fn new(
64 endpoint: impl Into<String>,
65 timeout: Duration,
66 ) -> Result<Arc<Self>, TraceExporterError> {
67 let endpoint = endpoint.into();
68 let client = if endpoint.is_empty() {
69 None
70 } else {
71 Some(reqwest::Client::builder().timeout(timeout).build()?)
72 };
73 Ok(Arc::new(Self {
74 endpoint,
75 client,
76 timeout,
77 }))
78 }
79
80 /// Build a disabled exporter. `emit` is a no-op. No HTTP client
81 /// is constructed so this cannot fail. Use in tests and when the

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected