From 835873f95b7b29e0231fdc126e89b873ba32f231 Mon Sep 17 00:00:00 2001 From: onewe Date: Sat, 11 May 2024 14:20:33 +0800 Subject: [PATCH] add load invoker method --- dubbo/src/extension/mod.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dubbo/src/extension/mod.rs b/dubbo/src/extension/mod.rs index f08860fa..724b64c7 100644 --- a/dubbo/src/extension/mod.rs +++ b/dubbo/src/extension/mod.rs @@ -398,6 +398,42 @@ impl ExtensionDirectoryCommander { } } } + + pub async fn load_invoker(&self, url: Url) -> Result { + let url_str = url.to_string(); + info!("load invoker extension: {}", url_str); + + let (tx, rx) = oneshot::channel(); + + let send = self + .sender + .send(ExtensionOpt::Load(url, ExtensionType::Invoker, tx)) + .await; + + let Ok(_) = send else { + let err_msg = format!("load invoker extension failed: {}", url_str); + return Err(LoadExtensionError::new(err_msg).into()); + }; + + let extensions = rx.await; + + let Ok(extension) = extensions else { + let err_msg = format!("load invoker extension failed: {}", url_str); + return Err(LoadExtensionError::new(err_msg).into()); + }; + + let Ok(extensions) = extension else { + let err_msg = format!("load invoker extension failed: {}", url_str); + return Err(LoadExtensionError::new(err_msg).into()); + }; + + match extensions { + Extensions::Invoker(proxy) => Ok(proxy), + _ => { + panic!("load invoker extension failed: invalid extension type"); + } + } + } } enum ExtensionOpt {