Module idempotency

Module idempotency 

Source
Expand description

Idempotency tracking system Idempotency key tracking system

Ensures scraping operations can be safely retried without re-executing expensive work. Each operation is tagged with a ULID-based key; results are stored in the cache with configurable TTL (default 24 h).

§Example

use stygian_graph::domain::idempotency::{IdempotencyKey, IdempotencyStore};
use stygian_graph::adapters::cache::MemoryCache;
use stygian_graph::ports::ServiceOutput;
use serde_json::json;
use std::sync::Arc;

let cache = Arc::new(MemoryCache::new());
let store = IdempotencyStore::new(cache);

let key = IdempotencyKey::generate();
let result = ServiceOutput { data: "page html".into(), metadata: json!({}) };

store.store(key, result.clone(), None).await.unwrap();
let cached = store.get(key).await.unwrap();
assert!(cached.is_some());

Structs§

CachedOutput
Serializable version of ServiceOutput for cache storage
IdempotencyKey
An idempotency key for a scraping operation.
IdempotencyRecord
A stored idempotency record.
IdempotencyStore
Cache-backed store for idempotency records.

Enums§

OperationStatus
Status of an idempotent operation

Constants§

DEFAULT_TTL
Default time-to-live for idempotency records (24 hours)
MAX_TTL
Maximum time-to-live for idempotency records (72 hours)