Skip to content

Commit 2da096f

Browse files
committed
feat: add thermal state to rocket
1 parent f35ead5 commit 2da096f

File tree

7 files changed

+25
-2
lines changed

7 files changed

+25
-2
lines changed

rust/src/daemon/launch_daemon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ impl Daemon {
328328
self.audio_stream.clone(),
329329
Some(Arc::clone(&self.visualization_state)),
330330
Some(Arc::clone(&self.streaming_registry)),
331+
Some(self.thermal_regulation_state.clone()),
331332
)
332333
.await;
333334

rust/src/visualization/server/builder.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::acquisition::SharedAudioStream;
1313
use crate::config::{Config, GenerixConfig};
1414
use crate::include_png_as_base64;
1515
use crate::processing::nodes::streaming_registry::StreamingNodeRegistry;
16+
use crate::thermal_regulation::SharedThermalState;
1617
use crate::visualization::api::graph::graph::*;
1718
use crate::visualization::api::*;
1819
use crate::visualization::auth::{
@@ -51,6 +52,7 @@ use tokio::sync::RwLock;
5152
/// * `audio_stream` - Optional shared audio stream for real-time audio endpoints
5253
/// * `visualization_state` - Optional shared visualization state for statistics
5354
/// * `streaming_registry` - Optional streaming node registry for audio processing
55+
/// * `thermal_state` - Optional shared thermal regulation state for temperature control
5456
///
5557
/// ### Returns
5658
///
@@ -72,7 +74,7 @@ use tokio::sync::RwLock;
7274
/// async fn example() {
7375
/// let figment = Figment::from(rocket::Config::default());
7476
/// let config = Arc::new(RwLock::new(Config::default()));
75-
/// let rocket = server::build_rocket(figment, config, None, None, None).await;
77+
/// let rocket = server::build_rocket(figment, config, None, None, None, None).await;
7678
/// // Launch the server
7779
/// // rocket.launch().await.expect("Failed to launch");
7880
/// }
@@ -83,6 +85,7 @@ pub async fn build_rocket(
8385
audio_stream: Option<Arc<SharedAudioStream>>,
8486
visualization_state: Option<Arc<SharedVisualizationState>>,
8587
streaming_registry: Option<Arc<StreamingNodeRegistry>>,
88+
thermal_state: Option<SharedThermalState>,
8689
) -> Rocket<Build> {
8790
// Load hmac secret from config
8891
let config_read = config.read().await;
@@ -202,6 +205,15 @@ pub async fn build_rocket(
202205
.manage(jwt_validator)
203206
.manage(config.clone()); // Add config as managed state for future dynamic configuration
204207

208+
// Add thermal regulation state if available
209+
let rocket_builder = if let Some(thermal_state) = thermal_state {
210+
debug!("Adding SharedThermalState to Rocket state management");
211+
rocket_builder.manage(thermal_state)
212+
} else {
213+
debug!("No thermal state provided, thermal regulation API will return 404");
214+
rocket_builder
215+
};
216+
205217
// Attach compression fairing if enabled in config and not using VITE_DEVELOPMENT
206218
// VITE_DEVELOPMENT is an environment variable for proxying Vite dev server
207219
let rocket_builder = if compression_config && !std::env::var("VITE_DEVELOPMENT").is_ok() {

rust/src/visualization/server/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
//! .merge(("hmac_secret", "your-secret-key".to_string()));
5050
//!
5151
//! let config = Arc::new(RwLock::new(Config::default()));
52-
//! let rocket = server::build_rocket(figment, config, None, None, None).await;
52+
//! let rocket = server::build_rocket(figment, config, None, None, None, None).await;
5353
//! rocket.launch().await.expect("Failed to launch server");
5454
//! }
5555
//! ```

rust/tests/api_jwt_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async fn test_protected_api_with_jwt() {
5252
None,
5353
Some(visualization_state),
5454
None,
55+
None,
5556
)
5657
.await;
5758
let client = rocket::local::asynchronous::Client::tracked(rocket)

rust/tests/rs256_jwt_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ async fn test_oidc_endpoints_with_rs256() {
194194
None,
195195
None,
196196
None,
197+
None,
197198
)
198199
.await;
199200

@@ -287,6 +288,7 @@ async fn test_token_endpoint_with_rs256() {
287288
None,
288289
None,
289290
None,
291+
None,
290292
)
291293
.await;
292294

rust/tests/rs256_pkce_flow_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ async fn test_rs256_pkce_flow_s256() {
480480
None,
481481
None,
482482
None,
483+
None,
483484
)
484485
.await;
485486

@@ -555,6 +556,7 @@ async fn test_rs256_pkce_flow_plain() {
555556
None,
556557
None,
557558
None,
559+
None,
558560
)
559561
.await;
560562

@@ -636,6 +638,7 @@ async fn test_rs256_pkce_flow() {
636638
None,
637639
None,
638640
None,
641+
None,
639642
)
640643
.await;
641644

@@ -682,6 +685,7 @@ async fn test_rs256_jwks_endpoint() {
682685
None,
683686
None,
684687
None,
688+
None,
685689
)
686690
.await;
687691

@@ -768,6 +772,7 @@ async fn test_rs256_pkce_invalid_challenge_method() {
768772
None,
769773
None,
770774
None,
775+
None,
771776
)
772777
.await;
773778

rust/tests/server_test_only.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ async fn test_oauth2_pkce_flow() {
122122
None,
123123
None,
124124
None,
125+
None,
125126
)
126127
.await;
127128
let client = Client::tracked(rocket)
@@ -390,6 +391,7 @@ async fn test_oauth2_invalid_credentials() {
390391
None,
391392
None,
392393
None,
394+
None,
393395
)
394396
.await;
395397
let client = Client::tracked(rocket)

0 commit comments

Comments
 (0)