Skip to main content

reifydb_core/actors/
replication.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use reifydb_runtime::actor::{reply::Reply, system::ActorHandle};
5use reifydb_type::error::Error;
6
7use crate::{
8	common::CommitVersion,
9	interface::cdc::{CdcBatch, SystemChange},
10};
11
12/// Handle to the replication primary actor.
13pub type ReplicationPrimaryHandle = ActorHandle<ReplicationPrimaryMessage>;
14
15/// Messages for the replication primary actor.
16pub enum ReplicationPrimaryMessage {
17	/// Read a batch of CDC entries starting after `since_version`.
18	ReadCdcBatch {
19		since_version: CommitVersion,
20		batch_size: u64,
21		reply: Reply<Result<CdcBatch, Error>>,
22	},
23	/// Get the current CDC version range.
24	GetVersion {
25		reply: Reply<Result<VersionInfo, Error>>,
26	},
27}
28
29/// CDC version range returned by the primary.
30pub struct VersionInfo {
31	pub current: Option<CommitVersion>,
32	pub min_cdc: Option<CommitVersion>,
33	pub max_cdc: Option<CommitVersion>,
34}
35
36/// Handle to the replication replica actor.
37pub type ReplicationReplicaHandle = ActorHandle<ReplicationReplicaMessage>;
38
39/// Messages for the replication replica actor.
40pub enum ReplicationReplicaMessage {
41	/// Apply system changes at a given version.
42	ApplyEntry {
43		version: CommitVersion,
44		system_changes: Vec<SystemChange>,
45		reply: Reply<Result<(), Error>>,
46	},
47	/// Get the last applied version.
48	GetCurrentVersion {
49		reply: Reply<CommitVersion>,
50	},
51}