raftoral/lib.rs
1pub mod raft;
2pub mod grpc; // gRPC implementation for generic architecture
3pub mod kv; // KV runtime for generic architecture
4pub mod management; // Management runtime for generic architecture
5pub mod workflow; // Workflow execution runtime for generic architecture
6pub mod full_node; // Complete node stack (Layer 0-7)
7pub mod config; // Configuration for Raftoral nodes
8
9/// Create a replicated variable with an explicit key.
10///
11/// This macro creates a ReplicatedVar with a user-provided key that remains stable
12/// across code changes and workflow versions.
13///
14/// # Example
15///
16/// ```ignore
17/// let mut counter = checkpoint!(ctx, "counter", 0i32);
18/// let history = checkpoint!(ctx, "history", Vec::<String>::new());
19/// ```
20///
21/// The variable can then be used with:
22/// - `*counter` - to read the value (via Deref)
23/// - `counter.set(value)` - to update the value
24/// - `counter.update(|v| ...)` - to atomically update
25#[macro_export]
26macro_rules! checkpoint {
27 ($ctx:expr, $key:literal, $value:expr) => {
28 $ctx.create_replicated_var($key, $value).await?
29 };
30}
31
32/// Create a replicated variable from a computed value (side effect).
33///
34/// This macro executes the provided computation once and stores the result
35/// in the Raft cluster. Useful for side effects like API calls or database queries
36/// that should only be executed once and have their results replicated.
37///
38/// # Example
39///
40/// ```ignore
41/// let api_data = checkpoint_compute!(ctx, "api_data", || async {
42/// fetch_from_external_api().await
43/// });
44/// ```
45#[macro_export]
46macro_rules! checkpoint_compute {
47 ($ctx:expr, $key:literal, $computation:expr) => {
48 $ctx.create_replicated_var_with_computation($key, $computation).await?
49 };
50}
51
52// Re-export common types for convenience
53pub use config::RaftoralConfig;