···3939 pub status: RepoStatus,
4040 pub rev: Option<DbTid>,
4141 pub data: Option<IpldCid>,
4242+ // todo: is this actually valid? the spec says this is informal and intermadiate
4343+ // services may change it. we should probably document it. if we cant use this
4444+ // then how do we dedup account / identity ops?
4545+ /// ms since epoch of the last firehose message we processed for this repo.
4646+ /// used to deduplicate identity / account events that can arrive from multiple relays at
4747+ /// different wall-clock times but represent the same underlying PDS event.
4848+ #[serde(default)]
4949+ pub last_message_time: Option<i64>,
4250 /// this is when we *ingested* any last updates
4351 pub last_updated_at: i64, // unix timestamp
4452 /// whether we are ingesting events for this repo
···6573 handle: None,
6674 pds: None,
6775 signing_key: None,
7676+ last_message_time: None,
6877 }
6978 }
7079···7685 }
7786 }
78878888+ // advances the high-water mark to event_ms if it's newer than what we've seen
8989+ pub fn advance_message_time(&mut self, event_ms: i64) {
9090+ self.last_message_time = Some(event_ms.max(self.last_message_time.unwrap_or(0)));
9191+ }
9292+9393+ // updates last_updated_at to now
9494+ pub fn touch(&mut self) {
9595+ self.last_updated_at = chrono::Utc::now().timestamp();
9696+ }
9797+7998 pub fn update_from_doc(&mut self, doc: MiniDoc) -> bool {
8099 let new_signing_key = doc.key.map(From::from);
81100 let changed = self.pds.as_deref() != Some(doc.pds.as_str())
···102121 handle: self.handle.map(IntoStatic::into_static),
103122 pds: self.pds.map(IntoStatic::into_static),
104123 signing_key: self.signing_key.map(IntoStatic::into_static),
124124+ last_message_time: self.last_message_time,
105125 }
106126 }
107127}
+4-4
tests/common.nu
···6060export def start-hydrant [binary: string, db_path: string, port: int] {
6161 let log_file = $"($db_path)/hydrant.log"
6262 print $"starting hydrant - logs at ($log_file)..."
6363-6363+6464 let hydrant_vars = ($env | transpose k v | where k =~ "HYDRANT_" | reduce -f {} { |it, acc| $acc | upsert $it.k $it.v })
6565 let env_vars = {
6666 HYDRANT_DATABASE_PATH: ($db_path),
···6868 HYDRANT_API_PORT: ($port | into string),
6969 HYDRANT_ENABLE_DEBUG: "true",
7070 HYDRANT_DEBUG_PORT: ($port + 1 | into string),
7171- HYDRANT_LOG_LEVEL: "debug"
7171+ RUST_LOG: "debug,hyper=error,tokio=error,h2=error,tower=error,rustls=error"
7272 } | merge $hydrant_vars
73737474 let pid = (with-env $env_vars {
7575 sh -c $"($binary) >($log_file) 2>&1 & echo $!" | str trim | into int
7676 })
7777-7777+7878 print $"hydrant started with pid: ($pid)"
7979 { pid: $pid, log: $log_file }
8080}
···115115 print "backfill complete."
116116 return true
117117 }
118118-118118+119119 sleep 2sec
120120 }
121121 false