Skip to main content

drasi_bootstrap_application/
lib.rs

1// Copyright 2025 The Drasi Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![allow(unexpected_cfgs)]
16
17//! Application bootstrap plugin for Drasi
18//!
19//! This plugin provides the Application bootstrap provider implementation for replaying
20//! stored insert events during query subscription.
21//!
22//! # Example
23//!
24//! ```no_run
25//! use drasi_bootstrap_application::ApplicationBootstrapProvider;
26//!
27//! // Using the builder - creates with isolated storage
28//! let provider = ApplicationBootstrapProvider::builder().build();
29//!
30//! // Using the builder with shared storage
31//! use std::sync::Arc;
32//! use tokio::sync::RwLock;
33//! use drasi_core::models::SourceChange;
34//!
35//! let shared_data = Arc::new(RwLock::new(Vec::<SourceChange>::new()));
36//! let provider = ApplicationBootstrapProvider::builder()
37//!     .with_shared_data(shared_data)
38//!     .build();
39//!
40//! // Or using the constructor directly
41//! let provider = ApplicationBootstrapProvider::new();
42//! ```
43
44pub mod application;
45pub mod descriptor;
46
47pub use application::{ApplicationBootstrapProvider, ApplicationBootstrapProviderBuilder};
48
49// Dynamic plugin entry point.
50// Core plugin — registered statically by the server, not exported for dynamic loading.
51
52#[cfg(test)]
53mod tests {
54    use super::*;
55    use drasi_core::models::SourceChange;
56    use std::sync::Arc;
57    use tokio::sync::RwLock;
58
59    #[test]
60    fn test_application_bootstrap_builder_isolated() {
61        // Builder without shared data creates isolated provider
62        let provider = ApplicationBootstrapProviderBuilder::new().build();
63        // Provider should exist (we can't easily test internal state)
64        let _ = provider;
65    }
66
67    #[test]
68    fn test_application_bootstrap_builder_with_shared_data() {
69        // Builder with shared data creates connected provider
70        let shared_data = Arc::new(RwLock::new(Vec::<SourceChange>::new()));
71        let provider = ApplicationBootstrapProviderBuilder::new()
72            .with_shared_data(shared_data.clone())
73            .build();
74        let _ = provider;
75    }
76
77    #[test]
78    fn test_application_bootstrap_from_provider_method() {
79        // Test using ApplicationBootstrapProvider::builder()
80        let provider = ApplicationBootstrapProvider::builder().build();
81        let _ = provider;
82    }
83
84    #[test]
85    fn test_application_bootstrap_new() {
86        // Test using ApplicationBootstrapProvider::new()
87        let provider = ApplicationBootstrapProvider::new();
88        let _ = provider;
89    }
90
91    #[test]
92    fn test_application_bootstrap_with_shared_data() {
93        // Test using ApplicationBootstrapProvider::with_shared_data()
94        let shared_data = Arc::new(RwLock::new(Vec::<SourceChange>::new()));
95        let provider = ApplicationBootstrapProvider::with_shared_data(shared_data);
96        let _ = provider;
97    }
98
99    #[test]
100    fn test_application_bootstrap_builder_default() {
101        // Default builder should work
102        let provider = ApplicationBootstrapProviderBuilder::default().build();
103        let _ = provider;
104    }
105
106    #[test]
107    fn test_application_bootstrap_provider_default() {
108        // ApplicationBootstrapProvider::default() should work
109        let provider = ApplicationBootstrapProvider::default();
110        let _ = provider;
111    }
112}