Skip to content

Commit

Permalink
add load invoker method
Browse files Browse the repository at this point in the history
  • Loading branch information
onewe committed May 11, 2024
1 parent 9cc8769 commit 835873f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions dubbo/src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,42 @@ impl ExtensionDirectoryCommander {
}
}
}

pub async fn load_invoker(&self, url: Url) -> Result<InvokerProxy, StdError> {
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 {
Expand Down

0 comments on commit 835873f

Please sign in to comment.