pub(crate) async fn run_sampler(
config_rx: Receiver<SampleConfig>,
shutdown_rx: Receiver<bool>,
js: Context,
) -> boolExpand description
Supervises LabJack sampling across config changes and transient failures.
Runs sample_with_config in a loop with the latest configuration. After a
configuration change it restarts at once; after an error it waits for
STREAMER_LABJACK_RETRY_DELAY_SECS first. While labjack_on_off is false it
waits for the next configuration change instead of opening the device. Any
session error counts as a failure, including NATS stream setup errors. The
failure count resets after a session that ends without error and while sampling
is disabled.
§Arguments
config_rx- Configuration channel fed bywatch_kv_config.shutdown_rx- Shutdown flag shared with the rest of the process.js- JetStream context of the local NATS server.
§Returns
true when consecutive failures reached STREAMER_MAX_LABJACK_FAILURES, which
lets the process exit cleanly instead of relying on service restarts. false
on shutdown, or when the configuration channel closes while sampling is
disabled.