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//! Application bootstrap plugin for Drasi
16//!
17//! This plugin provides the Application bootstrap provider implementation for replaying
18//! stored insert events during query subscription.
19//!
20//! # Example
21//!
22//! ```no_run
23//! use drasi_bootstrap_application::ApplicationBootstrapProvider;
24//!
25//! // Using the builder - creates with isolated storage
26//! let provider = ApplicationBootstrapProvider::builder().build();
27//!
28//! // Using the builder with shared storage
29//! use std::sync::Arc;
30//! use tokio::sync::RwLock;
31//! use drasi_core::models::SourceChange;
32//!
33//! let shared_data = Arc::new(RwLock::new(Vec::<SourceChange>::new()));
34//! let provider = ApplicationBootstrapProvider::builder()
35//!     .with_shared_data(shared_data)
36//!     .build();
37//!
38//! // Or using the constructor directly
39//! let provider = ApplicationBootstrapProvider::new();
40//! ```
41
42pub mod application;
43
44pub use application::{ApplicationBootstrapProvider, ApplicationBootstrapProviderBuilder};
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49    use drasi_core::models::SourceChange;
50    use std::sync::Arc;
51    use tokio::sync::RwLock;
52
53    #[test]
54    fn test_application_bootstrap_builder_isolated() {
55        // Builder without shared data creates isolated provider
56        let provider = ApplicationBootstrapProviderBuilder::new().build();
57        // Provider should exist (we can't easily test internal state)
58        let _ = provider;
59    }
60
61    #[test]
62    fn test_application_bootstrap_builder_with_shared_data() {
63        // Builder with shared data creates connected provider
64        let shared_data = Arc::new(RwLock::new(Vec::<SourceChange>::new()));
65        let provider = ApplicationBootstrapProviderBuilder::new()
66            .with_shared_data(shared_data.clone())
67            .build();
68        let _ = provider;
69    }
70
71    #[test]
72    fn test_application_bootstrap_from_provider_method() {
73        // Test using ApplicationBootstrapProvider::builder()
74        let provider = ApplicationBootstrapProvider::builder().build();
75        let _ = provider;
76    }
77
78    #[test]
79    fn test_application_bootstrap_new() {
80        // Test using ApplicationBootstrapProvider::new()
81        let provider = ApplicationBootstrapProvider::new();
82        let _ = provider;
83    }
84
85    #[test]
86    fn test_application_bootstrap_with_shared_data() {
87        // Test using ApplicationBootstrapProvider::with_shared_data()
88        let shared_data = Arc::new(RwLock::new(Vec::<SourceChange>::new()));
89        let provider = ApplicationBootstrapProvider::with_shared_data(shared_data);
90        let _ = provider;
91    }
92
93    #[test]
94    fn test_application_bootstrap_builder_default() {
95        // Default builder should work
96        let provider = ApplicationBootstrapProviderBuilder::default().build();
97        let _ = provider;
98    }
99
100    #[test]
101    fn test_application_bootstrap_provider_default() {
102        // ApplicationBootstrapProvider::default() should work
103        let provider = ApplicationBootstrapProvider::default();
104        let _ = provider;
105    }
106}