Enhance development workflow and deployment practices for Archipelago
- Updated the Development-Workflow documentation to clarify deployment strategy, emphasizing direct deployment to the live system for testing. - Added detailed instructions for the deployment command, including syncing code, building frontend and backend, and restarting services. - Improved SSH key management section to assist with authentication issues. - Expanded the testing workflow to include steps for checking logs and syncing changes back to the ISO build. - Updated the ISO build integration section to ensure system-level changes are captured for future builds. - Refactored various sections for clarity and completeness, including deployment paths and system configuration files.
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
use crate::data_model::{DataModel, WebSocketMessage};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::sync::{broadcast, RwLock};
|
||||
use tracing::debug;
|
||||
|
||||
/// Manages the application state and broadcasts updates to WebSocket clients
|
||||
pub struct StateManager {
|
||||
data: Arc<RwLock<DataModel>>,
|
||||
revision: Arc<RwLock<u32>>,
|
||||
broadcast_tx: broadcast::Sender<WebSocketMessage>,
|
||||
}
|
||||
|
||||
impl StateManager {
|
||||
pub fn new() -> Self {
|
||||
let (broadcast_tx, _) = broadcast::channel(100);
|
||||
Self {
|
||||
data: Arc::new(RwLock::new(DataModel::new())),
|
||||
revision: Arc::new(RwLock::new(0)),
|
||||
broadcast_tx,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +27,31 @@ impl StateManager {
|
||||
(data, rev)
|
||||
}
|
||||
|
||||
/// Update the data model (will broadcast patches in the future)
|
||||
/// Subscribe to state updates
|
||||
pub fn subscribe(&self) -> broadcast::Receiver<WebSocketMessage> {
|
||||
self.broadcast_tx.subscribe()
|
||||
}
|
||||
|
||||
/// Update the data model and broadcast to all connected clients
|
||||
pub async fn update_data(&self, new_data: DataModel) {
|
||||
let mut data = self.data.write().await;
|
||||
let mut rev = self.revision.write().await;
|
||||
|
||||
*data = new_data;
|
||||
*data = new_data.clone();
|
||||
*rev += 1;
|
||||
|
||||
debug!("Data model updated to revision {}", *rev);
|
||||
|
||||
// TODO: In the future, compute JSON patches and broadcast to all connected clients
|
||||
// For now, clients will need to reconnect to get updates
|
||||
// Broadcast full data dump to all connected clients
|
||||
// In the future, we can optimize this by computing and sending JSON patches
|
||||
let message = WebSocketMessage {
|
||||
rev: *rev,
|
||||
data: Some(new_data),
|
||||
patch: None,
|
||||
};
|
||||
|
||||
// Ignore errors if no receivers are connected
|
||||
let _ = self.broadcast_tx.send(message);
|
||||
}
|
||||
|
||||
/// Get a WebSocket message with the current state
|
||||
|
||||
Reference in New Issue
Block a user