pub(crate) fn main() -> Result<(), Box<dyn Error>>Expand description
Starts the live NATS subscriber and appends decoded samples to CSV.
Reads the configuration listed in the module docs, creates the output directory,
connects to NATS with the credentials file, and subscribes to the live wildcard.
For each message it decodes a sampler::Scan and writes one row per value, with
sample i timestamped first_sample_unix_ns + i * sample_interval_ns. CSV files are
opened on first use per asset and channel token (see asset_for_subject) and kept
open. The file is flushed after each scan.
Messages that fail FlatBuffer decoding are logged to stderr and skipped. Scans
without a values vector are skipped silently. If a timestamp does not fit in
i64, the rest of that scan is dropped with a message on stderr.
Runs until the subscription ends.
§Errors
Returns an error if the output directory cannot be created, NATS_SERVERS is
invalid, the credentials file cannot be loaded, the connection or subscription
fails, or writing or flushing a CSV file fails.
§Panics
Panics if a per-channel CSV file cannot be opened or its header written.