pub struct GrpcCaller { /* private fields */ }Expand description
gRPC 分支调用器,带 channel 缓存。
用 connect_lazy 而不是 connect:连接在首次真正发请求时才建立,
断了之后 tonic 自己重连。所以缓存里的 channel 不会因为对方重启而变成死的,
不需要额外的健康检查和淘汰逻辑。
Implementations§
Source§impl GrpcCaller
impl GrpcCaller
Sourcepub fn new(timeout: Duration) -> Self
pub fn new(timeout: Duration) -> Self
DTMRS_GRPC_CA 指向一个 PEM 文件时,把它加进信任列表。
读不到就只是不加,不 panic —— 推进器是常驻的, 因为一个可选配置起不来比连不上更糟。
Sourcepub fn with_ca_pem(self, pem: impl Into<Vec<u8>>) -> Self
pub fn with_ca_pem(self, pem: impl Into<Vec<u8>>) -> Self
直接指定额外信任的 CA(PEM 内容)。测试和嵌入式宿主用,绕开环境变量。
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