pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
pub fn new() -> Self
pub fn with_protocol_config(self, config: ProtocolConfig) -> Self
pub fn with_url(self, url: impl Into<String>) -> Self
Sourcepub fn with_filter(self, filter: Box<dyn Filter>) -> Self
pub fn with_filter(self, filter: Box<dyn Filter>) -> Self
Add a single filter to the client’s filter chain.
Filters execute in insertion order, outermost first.
Sourcepub fn with_filters(self, filters: Vec<Box<dyn Filter>>) -> Self
pub fn with_filters(self, filters: Vec<Box<dyn Filter>>) -> Self
Add multiple filters to the client’s filter chain.
Filters execute in the order given (index 0 is outermost).
Sourcepub fn with_cluster(self, cluster: Box<dyn Cluster>) -> Self
pub fn with_cluster(self, cluster: Box<dyn Cluster>) -> Self
Set a cluster fault-tolerance strategy for this client.
Sourcepub fn with_loadbalance(self, loadbalance: Box<dyn LoadBalance>) -> Self
pub fn with_loadbalance(self, loadbalance: Box<dyn LoadBalance>) -> Self
Set a load-balance strategy for this client.
Sourcepub fn with_registry(self, registry: Box<dyn Registry>) -> Self
pub fn with_registry(self, registry: Box<dyn Registry>) -> Self
Set a registry for service discovery.
When configured, the client will subscribe to the registry to
discover provider addresses dynamically instead of using the
single URL provided via with_url.
Sourcepub async fn dial(&mut self) -> Result<()>
pub async fn dial(&mut self) -> Result<()>
Establish a gRPC connection to the remote server.
Parses the URL to extract host and port, then creates a tonic
Channel. If filters are configured, wraps the invoker in a
FilterChain. Call this before making RPC requests.
§Errors
Returns an error if no URL is set, the URL is malformed, or the connection cannot be established.
Sourcepub fn channel(&self) -> Option<&Channel>
pub fn channel(&self) -> Option<&Channel>
Return a reference to the underlying tonic Channel, if connected.
Sourcepub fn invoker(&self) -> Option<&dyn Invoker>
pub fn invoker(&self) -> Option<&dyn Invoker>
Return a reference to the Dubbo Invoker, if connected.
The invoker is wrapped with the configured filter chain.
pub fn protocol_config(&self) -> Option<&ProtocolConfig>
pub fn url(&self) -> &str
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request