1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! # ppoppo-infra
//!
//! Backend-agnostic infrastructure traits for caching, queuing, and messaging.
//!
//! This crate defines the trait interfaces that backend implementations
//! (e.g., `ppoppo-pg` for PostgreSQL) implement. Consumers depend on
//! these traits for dependency injection, enabling backend swaps without
//! changing application code.
//!
//! ## Architecture
//!
//! ```text
//! ppoppo-infra (traits + types + decorators)
//! ├── ppoppo-pg (PostgreSQL impl) → JobQueue, Lock, BufferQueue
//! └── ppoppo-kvrocks (KVRocks impl) → Cache, Counter, RateLimit, PubSub
//! ```
//!
//! ## Traits
//!
//! | Trait / Type | Purpose |
//! |--------------|---------|
//! | [`Cache`] | Key-value store with TTL |
//! | [`Counter`] | Atomic increment/decrement |
//! | [`JobQueue`] | Reliable background job processing |
//! | [`Lock`] | Distributed locking |
//! | [`Publisher`] | Pub/sub messaging (write side) |
//! | [`Subscriber`] | Pub/sub messaging (read side) |
//! | [`PubSub`] | Composite: Publisher + Subscriber creation |
//! | [`RateLimit`] | Sliding window rate limiter |
//! | [`ResilientRateLimit`] | Fail-open decorator for any RateLimit impl |
//!
//! ## Extension Traits
//!
//! [`CacheExt`], [`JobQueueExt`], and [`PublisherExt`] provide typed
//! convenience methods (using `Serialize`/`DeserializeOwned`) on top
//! of the `serde_json::Value`-based core traits.
//!
//! ```rust,ignore
//! use ppoppo_infra::{Cache, CacheExt};
//!
//! async fn example(cache: &dyn Cache) {
//! // Core trait: serde_json::Value
//! cache.set("key", &json!({"name": "Alice"}), Some(300)).await?;
//!
//! // Extension: typed convenience
//! cache.set_typed("key", &user, Some(300)).await?;
//! let user: Option<User> = cache.get_typed("key").await?;
//! }
//! ```
// Re-export traits
pub use Cache;
pub use Counter;
pub use ;
pub use ;
pub use JobQueue;
pub use ;
pub use Publisher;
pub use PubSub;
pub use RateLimit;
pub use ResilientRateLimit;
pub use ;
pub use StagingWriter;
pub use Subscriber;
// Re-export types
pub use ;
// ═══════════════════════════════════════════════════════════════════════════════
// Compile-time assertions (RNAA §5)
// ═══════════════════════════════════════════════════════════════════════════════
assert_impl_all!;