pub struct GrpcCaller { /* private fields */ }Expand description
gRPC 分支调用器,带 channel 缓存。
用 connect_lazy 而不是 connect:连接在首次真正发请求时才建立,
断了之后 tonic 自己重连。所以缓存里的 channel 不会因为对方重启而变成死的,
不需要额外的健康检查和淘汰逻辑。
Implementations§
Source§impl GrpcCaller
impl GrpcCaller
pub fn new(timeout: Duration) -> Self
Sourcepub async fn call(
&self,
target: &GrpcTarget,
gid: &str,
trans_type: &str,
branch_id: &str,
op: &str,
) -> BranchResult
pub async fn call( &self, target: &GrpcTarget, gid: &str, trans_type: &str, branch_id: &str, op: &str, ) -> BranchResult
调一个 gRPC 分支。任何失败都不会返回 BranchResult::Failure ——
只有对方明确返回 ABORTED 才算业务要求回滚。
Trait Implementations§
Source§impl Clone for GrpcCaller
impl Clone for GrpcCaller
Source§fn clone(&self) -> GrpcCaller
fn clone(&self) -> GrpcCaller
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GrpcCaller
impl RefUnwindSafe for GrpcCaller
impl Send for GrpcCaller
impl Sync for GrpcCaller
impl Unpin for GrpcCaller
impl UnsafeUnpin for GrpcCaller
impl UnwindSafe for GrpcCaller
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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>
Wrap the input message
T in a tonic::Request