mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-28 05:45:48 +00:00
encap admin handler init/fini in crate
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
38a24e0170
commit
0e580292a6
|
@ -17,7 +17,6 @@ extern crate conduit_core as conduit;
|
|||
extern crate conduit_service as service;
|
||||
|
||||
pub(crate) use conduit::{mod_ctor, mod_dtor, Result};
|
||||
pub use handler::handle;
|
||||
pub(crate) use service::{services, user_is_local};
|
||||
|
||||
pub(crate) use crate::{
|
||||
|
@ -28,6 +27,18 @@ pub(crate) use crate::{
|
|||
mod_ctor! {}
|
||||
mod_dtor! {}
|
||||
|
||||
/// Install the admin command handler
|
||||
#[allow(clippy::let_underscore_must_use)]
|
||||
pub async fn init() {
|
||||
_ = services().admin.handle.lock().await.insert(handler::handle);
|
||||
}
|
||||
|
||||
/// Uninstall the admin command handler
|
||||
#[allow(clippy::let_underscore_must_use)]
|
||||
pub async fn fini() {
|
||||
_ = services().admin.handle.lock().await.take();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use clap::Parser;
|
||||
|
|
|
@ -22,7 +22,7 @@ pub(crate) async fn run(server: Arc<Server>) -> Result<(), Error> {
|
|||
let app = layers::build(&server)?;
|
||||
|
||||
// Install the admin room callback here for now
|
||||
_ = services().admin.handle.lock().await.insert(admin::handle);
|
||||
admin::init().await;
|
||||
|
||||
// Setup shutdown/signal handling
|
||||
let handle = ServerHandle::new();
|
||||
|
@ -39,7 +39,7 @@ pub(crate) async fn run(server: Arc<Server>) -> Result<(), Error> {
|
|||
_ = sigs.await;
|
||||
|
||||
// Remove the admin room callback
|
||||
_ = services().admin.handle.lock().await.take();
|
||||
admin::fini().await;
|
||||
|
||||
debug_info!("Finished");
|
||||
res
|
||||
|
|
Loading…
Reference in a new issue