ingest_demo/
ingest_demo.rs1use chrono::{DateTime, NaiveDate, Utc};
2use ingest::{
3 ingest, CanonicalIngestRecord, IngestConfig, IngestMetadata, IngestPayload, IngestSource,
4 RawIngestRecord,
5};
6
7fn fixed_timestamp() -> DateTime<Utc> {
8 let Some(date) = NaiveDate::from_ymd_opt(2024, 1, 1) else {
9 panic!("invalid date components");
10 };
11 let Some(date_time) = date.and_hms_opt(12, 0, 0) else {
12 panic!("invalid time components");
13 };
14 DateTime::<Utc>::from_naive_utc_and_offset(date_time, Utc)
15}
16
17fn main() {
18 let record = RawIngestRecord {
19 id: "ingest-demo".into(),
20 source: IngestSource::RawText,
21 metadata: IngestMetadata {
22 tenant_id: Some("tenant1".into()),
23 doc_id: Some("doc1".into()),
24 received_at: Some(fixed_timestamp()),
25 original_source: None,
26 attributes: None,
27 },
28 payload: Some(IngestPayload::Text(
29 " Hello world\nThis is\tUC-FP ".into(),
30 )),
31 };
32
33 match ingest(record, &IngestConfig::default()) {
34 Ok(rec) => {
35 let CanonicalIngestRecord { .. } = rec;
36 println!("{rec:#?}");
37 }
38 Err(err) => eprintln!("ingest failed: {err}"),
39 }
40}