rename admin/handler to admin/processor
Handler is overused. Handler ought to mean the end-function handling the command. The command processor is the central dispatcher to the handler. Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
f4db6292b3
commit
f047675a63
3 changed files with 18 additions and 16 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
pub(crate) mod admin;
|
||||
pub(crate) mod command;
|
||||
pub(crate) mod handler;
|
||||
pub(crate) mod processor;
|
||||
mod tests;
|
||||
pub(crate) mod utils;
|
||||
|
||||
|
@ -36,14 +36,18 @@ conduit::mod_ctor! {}
|
|||
conduit::mod_dtor! {}
|
||||
conduit::rustc_flags_capture! {}
|
||||
|
||||
/// Install the admin command handler
|
||||
/// Install the admin command processor
|
||||
pub async fn init(admin_service: &service::admin::Service) {
|
||||
_ = admin_service
|
||||
.complete
|
||||
.write()
|
||||
.expect("locked for writing")
|
||||
.insert(handler::complete);
|
||||
_ = admin_service.handle.write().await.insert(handler::handle);
|
||||
.insert(processor::complete);
|
||||
_ = admin_service
|
||||
.handle
|
||||
.write()
|
||||
.await
|
||||
.insert(processor::dispatch);
|
||||
}
|
||||
|
||||
/// Uninstall the admin command handler
|
||||
|
|
|
@ -26,7 +26,7 @@ use ruma::{
|
|||
OwnedEventId,
|
||||
};
|
||||
use service::{
|
||||
admin::{CommandInput, CommandOutput, HandlerFuture, HandlerResult},
|
||||
admin::{CommandInput, CommandOutput, ProcessorFuture, ProcessorResult},
|
||||
Services,
|
||||
};
|
||||
use tracing::Level;
|
||||
|
@ -38,12 +38,12 @@ use crate::{admin, admin::AdminCommand, Command};
|
|||
pub(super) fn complete(line: &str) -> String { complete_command(AdminCommand::command(), line) }
|
||||
|
||||
#[must_use]
|
||||
pub(super) fn handle(services: Arc<Services>, command: CommandInput) -> HandlerFuture {
|
||||
pub(super) fn dispatch(services: Arc<Services>, command: CommandInput) -> ProcessorFuture {
|
||||
Box::pin(handle_command(services, command))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all, name = "admin")]
|
||||
async fn handle_command(services: Arc<Services>, command: CommandInput) -> HandlerResult {
|
||||
async fn handle_command(services: Arc<Services>, command: CommandInput) -> ProcessorResult {
|
||||
AssertUnwindSafe(Box::pin(process_command(services, &command)))
|
||||
.catch_unwind()
|
||||
.await
|
||||
|
@ -68,7 +68,7 @@ async fn process_command(services: Arc<Services>, input: &CommandInput) -> Comma
|
|||
.and_then(|content| reply(content, input.reply_id.clone()))
|
||||
}
|
||||
|
||||
fn handle_panic(error: &Error, command: CommandInput) -> HandlerResult {
|
||||
fn handle_panic(error: &Error, command: CommandInput) -> ProcessorResult {
|
||||
let link = "Please submit a [bug report](https://github.com/girlbossceo/conduwuit/issues/new). 🥺";
|
||||
let msg = format!("Panic occurred while processing command:\n```\n{error:#?}\n```\n{link}");
|
||||
let content = RoomMessageEventContent::notice_markdown(msg);
|
Loading…
Add table
Add a link
Reference in a new issue