aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 18:38:43 +0100
committertv <tv@krebsco.de>2026-10-31 18:38:43 +0100
commita65c491cfc1b0fea8860ad64ab29a6ee8ad0faef (patch)
treeeb5a4b4284ea448a3e3a64fc6824376510a24d40 /src
parent4a9f4507f3161791f80c8c25a6f0e9ccd3649c2c (diff)
move SyncSession to document
Diffstat (limited to 'src')
-rw-r--r--src/document/mod.rs13
-rw-r--r--src/document/sync.rs (renamed from src/state/session.rs)4
-rw-r--r--src/state/mod.rs3
-rw-r--r--src/state/peer.rs3
-rw-r--r--src/swarm/sync.rs2
-rw-r--r--src/transport/mod.rs4
6 files changed, 12 insertions, 17 deletions
diff --git a/src/document/mod.rs b/src/document/mod.rs
index 2230e47..671bf5d 100644
--- a/src/document/mod.rs
+++ b/src/document/mod.rs
@@ -36,6 +36,7 @@ pub(crate) mod lock;
pub(crate) mod meta;
pub(crate) mod replica;
pub(crate) mod store;
+pub(crate) mod sync;
#[cfg(test)]
mod tests {
@@ -53,17 +54,13 @@ mod tests {
}
}
- /// Automerge is used only in `document`, `remake` and the sync session
- /// (`state/session.rs`); the rest of the node names its types as `document`
- /// re-exports them and works through `document` (`architecture.md`, The document).
+ /// Automerge is used only in `document` and `remake`; the rest of the node names
+ /// its types as `document` re-exports them and works through `document`
+ /// (`architecture.md`, The document).
#[test]
fn automerge_stays_behind_document() {
let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
- let allowed = [
- src.join("document"),
- src.join("remake"),
- src.join("state").join("session.rs"),
- ];
+ let allowed = [src.join("document"), src.join("remake")];
let mut files = Vec::new();
sources(&src, &mut files);
let mut found = Vec::new();
diff --git a/src/state/session.rs b/src/document/sync.rs
index 7305c58..dc286fa 100644
--- a/src/state/session.rs
+++ b/src/document/sync.rs
@@ -14,8 +14,8 @@ use automerge::sync::{self, SyncDoc};
use tokio::time::Instant;
use tracing::debug;
+use super::Document;
use crate::backoff::Backoff;
-use crate::document::Document;
use crate::swarm::throughput::SyncBytes;
use crate::transport::SyncPayload;
@@ -334,7 +334,7 @@ impl SyncSession {
/// If the answer is overdue: forgets that the unanswered changes were sent and that
/// a message is in flight, so the next sync pass sends them again. Returns how many
/// changes that concerns.
- pub(super) fn take_overdue_reply(&mut self, now: Instant) -> Option<usize> {
+ pub(crate) fn take_overdue_reply(&mut self, now: Instant) -> Option<usize> {
if self.reply.as_ref().is_none_or(|wait| now < wait.deadline) {
return None;
}
diff --git a/src/state/mod.rs b/src/state/mod.rs
index 8ac1124..75c3780 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -2,7 +2,6 @@
//!
//! * `peer`: what a node knows about each peer (`PeerState`): standing, liveness,
//! handshake, incidents.
-//! * `session`: one Automerge sync with a peer (`SyncSession`).
//! * `timing`: the intervals the protocol runs on (`Timing`).
//! * `read`: serving reads, live or from the pre-rejoin copy.
//! * `host`: the node as the remake module sees it (`remake::Host`).
@@ -21,12 +20,10 @@
mod host;
mod peer;
mod read;
-mod session;
mod timing;
pub(crate) use peer::{HelloState, Incidents, Keepalive, Liveness, PeerState, Standing};
pub(crate) use read::{ReadSource, StaleView};
-pub(crate) use session::{SyncSession, decode as decode_sync};
pub(crate) use timing::Timing;
use std::collections::HashMap;
diff --git a/src/state/peer.rs b/src/state/peer.rs
index f6e8786..3e1332d 100644
--- a/src/state/peer.rs
+++ b/src/state/peer.rs
@@ -4,9 +4,10 @@ use std::time::Duration;
use tokio::time::Instant;
-use super::{SyncSession, Timing};
+use super::Timing;
use crate::backoff::Backoff;
use crate::document::replica::Epoch;
+use crate::document::sync::SyncSession;
use crate::transport;
/// How far a peer got into the swarm, as far as we're concerned.
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 3cbe5f3..35bc4c7 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -355,7 +355,7 @@ pub(crate) async fn handle_sync(
// to another epoch.
tokio::task::spawn_blocking(move || -> Result<Option<(bool, bool)>> {
// Before the lock: decoding a large message takes a while.
- let message = crate::state::decode_sync(&message)?;
+ let message = crate::document::sync::decode(&message)?;
let mut replica = doc.blocking_write();
// Authoritative check, under the same lock as the apply: the document may
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 61d54f2..2093e3d 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -680,8 +680,8 @@ impl DeltaSpec {
}
}
-/// A sync message as the document's engine encodes it (`state::session`): bytes to the
-/// transports. Decoded only where it is applied (`state::decode_sync`), after the sender
+/// A sync message as the document's engine encodes it (`document::sync`): bytes to the
+/// transports. Decoded only where it is applied (`document::sync::decode`), after the sender
/// proved to be a member and off the consumer: a large message from anyone else costs
/// nothing but its bytes.
#[derive(Clone)]