reddb_server/application/
native.rs1use std::collections::BTreeMap;
2
3use crate::application::ports::RuntimeNativePort;
4use crate::health::HealthReport;
5use crate::physical::{ExportDescriptor, ManifestEvent, PhysicalMetadataFile, SnapshotDescriptor};
6use crate::storage::engine::PhysicalFileHeader;
7use crate::storage::unified::devx::{
8 NativeVectorArtifactBatchInspection, NativeVectorArtifactInspection, PhysicalAuthorityStatus,
9};
10use crate::storage::unified::store::{
11 NativeCatalogSummary, NativeManifestSummary, NativeMetadataStateSummary, NativePhysicalState,
12 NativeRecoverySummary, NativeRegistrySummary, NativeVectorArtifactPageSummary,
13};
14use crate::RedDBResult;
15
16#[derive(Debug, Clone)]
17pub struct InspectNativeArtifactInput {
18 pub collection: String,
19 pub artifact_kind: Option<String>,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub struct RuntimeReadiness {
24 pub query: bool,
25 pub query_serverless: bool,
26 pub write: bool,
27 pub write_serverless: bool,
28 pub repair: bool,
29 pub repair_serverless: bool,
30}
31
32pub struct NativeUseCases<'a, P: ?Sized> {
33 runtime: &'a P,
34}
35
36impl<'a, P: RuntimeNativePort + ?Sized> NativeUseCases<'a, P> {
37 pub fn new(runtime: &'a P) -> Self {
38 Self { runtime }
39 }
40
41 pub fn collection_roots(&self) -> RedDBResult<BTreeMap<String, u64>> {
42 self.runtime.collection_roots()
43 }
44
45 pub fn health(&self) -> HealthReport {
46 self.runtime.health_report()
47 }
48
49 pub fn snapshots(&self) -> RedDBResult<Vec<SnapshotDescriptor>> {
50 self.runtime.snapshots()
51 }
52
53 pub fn exports(&self) -> RedDBResult<Vec<ExportDescriptor>> {
54 self.runtime.exports()
55 }
56
57 pub fn physical_metadata(&self) -> RedDBResult<PhysicalMetadataFile> {
58 self.runtime.physical_metadata()
59 }
60
61 pub fn manifest_events_filtered(
62 &self,
63 collection: Option<&str>,
64 kind: Option<&str>,
65 since_snapshot: Option<u64>,
66 ) -> RedDBResult<Vec<ManifestEvent>> {
67 self.runtime
68 .manifest_events_filtered(collection, kind, since_snapshot)
69 }
70
71 pub fn create_snapshot(&self) -> RedDBResult<SnapshotDescriptor> {
72 self.runtime.create_snapshot()
73 }
74
75 pub fn create_export(&self, name: String) -> RedDBResult<ExportDescriptor> {
76 self.runtime.create_export(name)
77 }
78
79 pub fn checkpoint(&self) -> RedDBResult<()> {
80 self.runtime.checkpoint()
81 }
82
83 pub fn apply_retention_policy(&self) -> RedDBResult<()> {
84 self.runtime.apply_retention_policy()
85 }
86
87 pub fn run_maintenance(&self) -> RedDBResult<()> {
88 self.runtime.run_maintenance()
89 }
90
91 pub fn native_header(&self) -> RedDBResult<PhysicalFileHeader> {
92 self.runtime.native_header()
93 }
94
95 pub fn native_collection_roots(&self) -> RedDBResult<BTreeMap<String, u64>> {
96 self.runtime.native_collection_roots()
97 }
98
99 pub fn native_manifest_summary(&self) -> RedDBResult<NativeManifestSummary> {
100 self.runtime.native_manifest_summary()
101 }
102
103 pub fn native_registry_summary(&self) -> RedDBResult<NativeRegistrySummary> {
104 self.runtime.native_registry_summary()
105 }
106
107 pub fn native_recovery_summary(&self) -> RedDBResult<NativeRecoverySummary> {
108 self.runtime.native_recovery_summary()
109 }
110
111 pub fn native_catalog_summary(&self) -> RedDBResult<NativeCatalogSummary> {
112 self.runtime.native_catalog_summary()
113 }
114
115 pub fn native_physical_state(&self) -> RedDBResult<NativePhysicalState> {
116 self.runtime.native_physical_state()
117 }
118
119 pub fn native_vector_artifact_pages(
120 &self,
121 ) -> RedDBResult<Vec<NativeVectorArtifactPageSummary>> {
122 self.runtime.native_vector_artifact_pages()
123 }
124
125 pub fn inspect_vector_artifact(
126 &self,
127 input: InspectNativeArtifactInput,
128 ) -> RedDBResult<NativeVectorArtifactInspection> {
129 self.runtime
130 .inspect_native_vector_artifact(&input.collection, input.artifact_kind.as_deref())
131 }
132
133 pub fn warmup_vector_artifact(
134 &self,
135 input: InspectNativeArtifactInput,
136 ) -> RedDBResult<NativeVectorArtifactInspection> {
137 self.runtime
138 .warmup_native_vector_artifact(&input.collection, input.artifact_kind.as_deref())
139 }
140
141 pub fn inspect_vector_artifacts(&self) -> RedDBResult<NativeVectorArtifactBatchInspection> {
142 self.runtime.inspect_native_vector_artifacts()
143 }
144
145 pub fn warmup_vector_artifacts(&self) -> RedDBResult<NativeVectorArtifactBatchInspection> {
146 self.runtime.warmup_native_vector_artifacts()
147 }
148
149 pub fn native_header_repair_policy(&self) -> RedDBResult<String> {
150 self.runtime.native_header_repair_policy()
151 }
152
153 pub fn repair_native_header_from_metadata(&self) -> RedDBResult<String> {
154 self.runtime.repair_native_header_from_metadata()
155 }
156
157 pub fn rebuild_physical_metadata_from_native_state(&self) -> RedDBResult<bool> {
158 self.runtime.rebuild_physical_metadata_from_native_state()
159 }
160
161 pub fn repair_native_physical_state_from_metadata(&self) -> RedDBResult<bool> {
162 self.runtime.repair_native_physical_state_from_metadata()
163 }
164
165 pub fn native_metadata_state_summary(&self) -> RedDBResult<NativeMetadataStateSummary> {
166 self.runtime.native_metadata_state_summary()
167 }
168
169 pub fn physical_authority_status(&self) -> PhysicalAuthorityStatus {
170 self.runtime.physical_authority_status()
171 }
172
173 pub fn readiness(&self) -> RuntimeReadiness {
174 RuntimeReadiness {
175 query: self.runtime.readiness_for_query(),
176 query_serverless: self.runtime.readiness_for_query_serverless(),
177 write: self.runtime.readiness_for_write(),
178 write_serverless: self.runtime.readiness_for_write_serverless(),
179 repair: self.runtime.readiness_for_repair(),
180 repair_serverless: self.runtime.readiness_for_repair_serverless(),
181 }
182 }
183}