MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / pending

Function pending

atomic-agent/src/hook_log.rs:193–219  ·  view source on GitHub ↗

Pending transport failures remain inspectable before a service recovers.

(
    root: &std::path::Path,
)

Source from the content-addressed store, hash-verified

191
192/// Pending transport failures remain inspectable before a service recovers.
193pub fn pending(
194 root: &std::path::Path,
195) -> Result<Vec<(std::path::PathBuf, SessionLogEvent)>, String> {
196 let dir = root.join(".atomic/hook-log-pending");
197 let entries = match std::fs::read_dir(dir) {
198 Ok(entries) => entries,
199 Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),
200 Err(error) => return Err(error.to_string()),
201 };
202 let mut events = Vec::new();
203 for entry in entries {
204 let path = entry.map_err(|error| error.to_string())?.path();
205 if path.extension().is_none_or(|extension| extension != "json") {
206 continue;
207 }
208 let bytes = match std::fs::read(&path) {
209 Ok(bytes) => bytes,
210 Err(error) if error.kind() == std::io::ErrorKind::NotFound => continue,
211 Err(error) => return Err(error.to_string()),
212 };
213 events.push((
214 path,
215 serde_json::from_slice(&bytes).map_err(|error| error.to_string())?,
216 ));
217 }
218 Ok(events)
219}
220
221/// Replay pending events idempotently while the service owns the database gate.
222pub fn flush_pending(

Callers 7

read_hook_activityFunction · 0.85
readFunction · 0.85
pending_healthFunction · 0.85
healthMethod · 0.85
flush_pendingFunction · 0.85

Calls 5

extensionMethod · 0.80
readFunction · 0.50
kindMethod · 0.45
pathMethod · 0.45
pushMethod · 0.45