mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-12 19:01:16 +00:00
35 lines
739 B
Rust
35 lines
739 B
Rust
![]() |
use std::sync::Arc;
|
||
|
|
||
|
use parking_lot::RwLock;
|
||
|
use tokio::sync::mpsc;
|
||
|
|
||
|
use flowy_user::event_map::UserAuthService;
|
||
|
|
||
|
use crate::local_server::user::LocalServerUserAuthServiceImpl;
|
||
|
use crate::AppFlowyServer;
|
||
|
|
||
|
#[derive(Default)]
|
||
|
pub struct LocalServer {
|
||
|
stop_tx: RwLock<Option<mpsc::Sender<()>>>,
|
||
|
}
|
||
|
|
||
|
impl LocalServer {
|
||
|
pub fn new() -> Self {
|
||
|
// let _config = self_host_server_configuration().unwrap();
|
||
|
Self::default()
|
||
|
}
|
||
|
|
||
|
pub async fn stop(&self) {
|
||
|
let sender = self.stop_tx.read().clone();
|
||
|
if let Some(stop_tx) = sender {
|
||
|
let _ = stop_tx.send(()).await;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl AppFlowyServer for LocalServer {
|
||
|
fn user_service(&self) -> Arc<dyn UserAuthService> {
|
||
|
Arc::new(LocalServerUserAuthServiceImpl())
|
||
|
}
|
||
|
}
|