Add notifier to break relay loop

This commit is contained in:
Tobias Reisinger 2023-12-07 04:30:33 +01:00
parent 83c1f033d5
commit 8785186dfa
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
12 changed files with 124 additions and 45 deletions
emgauwa-controller/src

View file

@ -1,9 +1,25 @@
use std::sync::Arc;
use actix::Addr;
use emgauwa_lib::errors::EmgauwaError;
use emgauwa_lib::models::Controller;
use tokio::sync::Notify;
use crate::app_state::{AppState, GetThis};
use crate::app_state;
use crate::app_state::AppState;
pub async fn get_this(app_state: &Addr<AppState>) -> Result<Controller, EmgauwaError> {
app_state.send(GetThis {}).await.map_err(EmgauwaError::from)
pub async fn app_state_get_this(app_state: &Addr<AppState>) -> Result<Controller, EmgauwaError> {
app_state
.send(app_state::GetThis {})
.await
.map_err(EmgauwaError::from)
}
pub async fn app_state_get_notifier(
app_state: &Addr<AppState>,
) -> Result<Arc<Notify>, EmgauwaError> {
app_state
.send(app_state::GetNotifier {})
.await
.map_err(EmgauwaError::from)
}