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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright (C) 2024-2025 Greg Burd. Licensed under either of the
// Apache License, Version 2.0 or the MIT license, at your option.
// See LICENSE-APACHE and LICENSE-MIT at the root of this repository.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! > **Internal component of the [`noxu`](https://crates.io/crates/noxu) database.**
//! >
//! > This crate is published only so the `noxu` umbrella crate can depend on it.
//! > Use `noxu` (`noxu = "3"`) in applications; depend on this crate directly only
//! > if you are extending the engine internals. Its API may change without a major
//! > version bump.
//!
//! Replication and high availability for Noxu DB.
//!
//! master-replica replication with
//! automatic elections, VLSN tracking, network restore, and subscription.
//!
//! # Architecture
//!
//! The replication layer consists of:
//!
//! - **ReplicatedEnvironment** -- Entry point that wraps a standard Environment
//! and adds replication capabilities.
//! Rep.ReplicatedEnvironment`.
//! - **Elections** -- Automatic master election using majority voting.
//! Rep.elections`.
//! - **VLSN Index** -- Maps version sequence numbers to log file positions.
//! - **Feeder/Replica Stream** -- Master-to-replica log entry streaming. Port
//! - **Network Transport** -- Pluggable channel-based communication.
//! Rep.net`.
//! - **Group Service** -- Replication group membership management.
//! - **Consistency Policies** -- Configurable replica consistency guarantees.
//! - **Master Transfer** -- Controlled transfer of master role.
//! - **Network Restore** -- Full node restore from another replica.
//! - **Subscription** -- External subscription to the replication stream.
//!
//! # Node States
//!
//! A replication node transitions through the following states:
//!
//! - **Detached** -- Not associated with the group (handle closed).
//! - **Unknown** -- Not in contact with the master, actively trying to
//! establish contact or decide upon a master.
//! - **Master** -- The unique master of the group; can read and write.
//! - **Replica** -- Being updated by the master; read-only.
//!
//! The state transitions visible to the application follow:
//! ```text
//! [ MASTER | REPLICA | UNKNOWN ]+ DETACHED
//! ```
//!
//! # Example
//!
//! ```ignore
//! use noxu_rep::{ReplicatedEnvironment, RepConfig, NodeType};
//!
//! let config = RepConfig::builder("my_group", "node1", "localhost")
//! .node_port(14_001)
//! .node_type(NodeType::Electable)
//! .build();
//! let rep_env = ReplicatedEnvironment::new(config).unwrap();
//! ```
// Foundation modules
// Election subsystem
// VLSN tracking subsystem
// Replication stream subsystem
// Node state management
// Group membership
// Acknowledgment tracking
// Statistics
// Master transfer
// Network transport
// TLS configuration
// Subscription API
// Network restore
// Main API
// In-memory `RepTestBase` / `RepEnvInfo` harness for porting JE rep
// tests and for production in-process clusters. Available under
// `cfg(any(test, feature = "test-harness"))` and as a first-class
// production module via [`net::InMemoryTransport`]. The
// `test-harness` feature flag is retained as a no-op for backward
// compatibility with downstream Cargo.toml entries.
// Re-export primary types
pub use ;
pub use ConsistencyPolicy;
pub use PhiAccrualDetector;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use NodeType;
pub use QuorumPolicy;
pub use RepConfig;
pub use RepTransportKind;
pub use RepGroup;
pub use RepNode;
pub use RepStats;
pub use ReplicatedEnvironment;
pub use ;
pub use ;
pub use ;
pub use TlsConfig;