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