pub use blocking_client::BlockingClient;
use cheetah_string::CheetahString;
pub use client::Client;
use crate::base::response_future::ResponseFuture;
use crate::protocol::remoting_command::RemotingCommand;
use crate::remoting::InvokeCallback;
use crate::remoting::RemotingService;
use crate::runtime::processor::RequestProcessor;
mod async_client;
mod blocking_client;
mod client;
pub mod connection_pool;
pub(crate) mod nameserver_selector;
pub mod reconnect;
pub mod rocketmq_tokio_client;
#[allow(async_fn_in_trait)]
pub trait RemotingClient: RemotingService {
async fn update_name_server_address_list(&self, addrs: Vec<CheetahString>);
fn get_name_server_address_list(&self) -> &[CheetahString];
fn get_available_name_srv_list(&self) -> Vec<CheetahString>;
async fn invoke_request(
&self,
addr: Option<&CheetahString>,
request: RemotingCommand,
timeout_millis: u64,
) -> rocketmq_error::RocketMQResult<RemotingCommand>;
async fn invoke_request_oneway(&self, addr: &CheetahString, request: RemotingCommand, timeout_millis: u64);
fn invoke_oneway_unbounded(&self, addr: CheetahString, request: RemotingCommand);
fn is_address_reachable(&mut self, addr: &CheetahString);
fn close_clients(&mut self, addrs: Vec<String>);
fn register_processor(&mut self, processor: impl RequestProcessor + Sync);
}
impl<T> InvokeCallback for T
where
T: Fn(Option<RemotingCommand>, Option<Box<dyn std::error::Error>>, Option<ResponseFuture>) + Send + Sync,
{
fn operation_complete(&self, response_future: ResponseFuture) {
self(None, None, Some(response_future))
}
fn operation_succeed(&self, response: RemotingCommand) {
self(Some(response), None, None)
}
fn operation_fail(&self, throwable: Box<dyn std::error::Error>) {
self(None, Some(throwable), None)
}
}