Skip to main content

reifydb_transaction/multi/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use std::time::Duration;
5
6use reifydb_core::common::CommitVersion;
7use reifydb_type::Result;
8
9use crate::multi::transaction::{
10	MultiTransaction, read::MultiReadTransaction, replica::MultiReplicaTransaction, write::MultiWriteTransaction,
11};
12
13pub mod conflict;
14pub mod marker;
15#[allow(clippy::module_inception)]
16pub mod multi;
17pub(crate) mod oracle;
18pub mod pending;
19pub mod transaction;
20pub mod types;
21pub mod watermark;
22
23impl MultiTransaction {
24	/// Get the current version from the transaction manager
25	pub fn current_version(&self) -> Result<CommitVersion> {
26		self.tm.version()
27	}
28
29	/// Returns the highest version where ALL prior versions have completed.
30	/// This is useful for CDC polling to know the safe upper bound for fetching
31	/// CDC events - all events up to this version are guaranteed to be in storage.
32	pub fn done_until(&self) -> CommitVersion {
33		self.tm.done_until()
34	}
35
36	/// Wait for the watermark to reach the given version with a timeout.
37	/// Returns true if the watermark reached the target, false if timeout occurred.
38	pub fn wait_for_mark_timeout(&self, version: CommitVersion, timeout: Duration) -> bool {
39		self.tm.wait_for_mark_timeout(version, timeout)
40	}
41
42	/// Advance the version state for replica replication.
43	///
44	/// This must only be called from the replica applier in sequential version order.
45	pub fn advance_version_for_replica(&self, version: CommitVersion) {
46		self.tm.advance_version_for_replica(version);
47	}
48}