pub struct Spectra { /* private fields */ }Expand description
Handle to an installed process-wide Spectra runtime.
Keep this value to access the configured SpectraRouter. Building installs the emit
configuration, router, and sink globally; applications should build once during startup.
§Examples
use std::sync::Arc;
use spectra_backend_mem::{MemEventsBackend, MemMetricsBackend};
use spectra_runtime::Spectra;
let spectra = Spectra::builder()
.metrics_backend(Arc::new(MemMetricsBackend::new()))
.events_backend(Arc::new(MemEventsBackend::new()))
.embedded()
.build()?;
let router = spectra.router();Implementations§
Source§impl Spectra
impl Spectra
Sourcepub fn router(&self) -> Arc<SpectraRouter>
pub fn router(&self) -> Arc<SpectraRouter>
Returns the installed global router (metrics/events query and backend resolution).
Sourcepub fn is_embedded(&self) -> bool
pub fn is_embedded(&self) -> bool
Whether this runtime was marked as in-process embedded topology.
Set by SpectraBuilder::embedded. This is a topology marker only — it does not
select, validate, or change storage backends.
Sourcepub async fn flush_persist(&self) -> Result<(), Error>
pub async fn flush_persist(&self) -> Result<(), Error>
Wait until every persist job enqueued before this call has been written to storage.
Use after try_record_*_now / generated helpers when a script must exit only after
durable writes complete. No-op when persist was disabled at build time.
Sourcepub fn builder() -> SpectraBuilder
pub fn builder() -> SpectraBuilder
Start building a process-scoped Spectra runtime with explicit storage injection.
§Examples
use spectra_backend_mem::{MemEventsBackend, MemMetricsBackend};
use spectra_runtime::Spectra;
let _spectra = Spectra::builder()
.metrics_backend(Arc::new(MemMetricsBackend::new()))
.events_backend(Arc::new(MemEventsBackend::new()))
.embedded()
.build()?;