MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / query_changes

Method query_changes

nodedb/src/control/change_stream/stream.rs:250–265  ·  view source on GitHub ↗

Query recent changes for a collection since a given timestamp. Returns change events matching the collection filter that occurred at or after `since_ms` (epoch milliseconds). Limited to the ring buffer capacity (most recent N events).

(
        &self,
        collection: Option<&str>,
        since_ms: u64,
        limit: usize,
    )

Source from the content-addressed store, hash-verified

248 /// at or after `since_ms` (epoch milliseconds). Limited to the ring
249 /// buffer capacity (most recent N events).
250 pub fn query_changes(
251 &self,
252 collection: Option<&str>,
253 since_ms: u64,
254 limit: usize,
255 ) -> Vec<ChangeEvent> {
256 let buf = match self.recent_changes.read() {
257 Ok(b) => b,
258 Err(p) => p.into_inner(),
259 };
260 buf.iter()
261 .filter(|e| e.timestamp_ms >= since_ms && collection.is_none_or(|c| e.collection == c))
262 .take(limit)
263 .cloned()
264 .collect()
265 }
266
267 /// Manually decrement the active subscription counter.
268 ///

Callers 7

dispatchFunction · 0.80
sse_streamFunction · 0.80
poll_changesFunction · 0.80
process_messageFunction · 0.80

Calls 4

collectMethod · 0.80
readMethod · 0.45
takeMethod · 0.45
iterMethod · 0.45