Skip to main content

reifydb_core/actors/
replication.rs

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