Skip to main content

run_worker

Function run_worker 

Source
pub(crate) async fn run_worker(parquet_root: PathBuf) -> Result<()>
Expand description

Runs exporter worker mode by subscribing to one NATS request subject.

Connects with connect_nats_from_env and subscribes to <NATS_SUBJECT>.<SITE_ID>.<box>.<source>.export.request built by subjects::archive_export_request_subject. Each incoming request is handled in its own Tokio task, with no limit on concurrent exports, and answered on the message’s reply subject by process_nats_request. Requests without a reply subject are logged and dropped. If a request fails, the error is logged and a best-effort error frame ({"type":"error","message":...}) is published to the reply subject, possibly after meta and some chunk frames were already sent.

§Arguments

  • parquet_root - Root of the Parquet archive.

§Returns

Ok(()) when the subscription ends.

§Errors

Returns an error if the NATS connection fails, if neither EXPORT_BOX_ID nor BOX_ID is set, or if the subscription cannot be created.