linkrs_sync/manager/
types.rs1#[cfg(feature = "fulltext")]
3use crate::coordinator::CoordinatorError;
4use linkrs_core::Value;
5#[derive(Debug, Clone)]
6pub struct IndexCreateRequest {
7 pub space_id: u64,
8 pub index_name: String,
9 pub schema_name: String,
10 pub index_type: String,
11 pub fields: Vec<(String, Value)>,
12 pub properties: Vec<String>,
13}
14#[derive(Debug, Clone)]
16pub struct OutboxConsumerConfig {
17 pub consumer_id: String,
18 pub batch_size: usize,
19 pub lease_duration_ms: u64,
20 pub max_retries: u64,
21 pub max_concurrency: usize,
24}
25impl Default for OutboxConsumerConfig {
26 fn default() -> Self {
27 Self {
28 consumer_id: format!("sync-manager-{}", uuid::Uuid::new_v4()),
29 batch_size: 128,
30 lease_duration_ms: 30_000,
31 max_retries: 16,
32 max_concurrency: 1,
33 }
34 }
35}
36#[derive(Debug, Clone)]
38pub struct OutboxBackpressureConfig {
39 pub max_pending_per_txn: usize,
41 pub max_pending_total: usize,
45}
46impl Default for OutboxBackpressureConfig {
47 fn default() -> Self {
48 Self {
49 max_pending_per_txn: 10_000,
50 max_pending_total: 100_000,
51 }
52 }
53}
54#[derive(Debug, Clone)]
55pub struct EdgeRef<'a> {
56 pub src: &'a Value,
57 pub dst: &'a Value,
58 pub edge_type: &'a str,
59}
60impl<'a> EdgeRef<'a> {
61 pub fn new(src: &'a Value, dst: &'a Value, edge_type: &'a str) -> Self {
62 Self {
63 src,
64 dst,
65 edge_type,
66 }
67 }
68
69 pub fn id(&self) -> String {
70 format!("{}->{}", self.src, self.dst)
71 }
72}
73#[derive(Debug, Clone)]
74pub struct EdgeProps<'a> {
75 pub old: &'a [(String, Value)],
76 pub new: &'a [(String, Value)],
77}
78impl<'a> EdgeProps<'a> {
79 pub fn new(old: &'a [(String, Value)], new: &'a [(String, Value)]) -> Self {
80 Self { old, new }
81 }
82}
83#[derive(Debug, thiserror::Error)]
84pub enum SyncError {
85 #[cfg(feature = "fulltext")]
86 #[error("Coordinator error: {0}")]
87 CoordinatorError(#[from] CoordinatorError),
88
89 #[cfg(feature = "fulltext")]
90 #[error("Sync coordinator error: {0}")]
91 SyncCoordinatorError(#[from] crate::coordinator::SyncCoordinatorError),
92
93 #[error("Buffer error: {0}")]
94 BufferError(String),
95
96 #[error("Vector error: {0}")]
97 VectorError(String),
98
99 #[error("Persistence error: {0}")]
100 PersistenceError(String),
101
102 #[error("Outbox backpressure: {0}")]
103 OutboxBackpressure(String),
104
105 #[error("Rebuild busy: {0}")]
106 RebuildBusy(String),
107
108 #[error("Internal error: {0}")]
109 Internal(String),
110}