pub struct TcClient<T> { /* private fields */ }Implementations§
Source§impl<T> TcClient<T>where
T: GrpcService<Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
impl<T> TcClient<T>where
T: GrpcService<Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
pub fn new(inner: T) -> Self
pub fn with_origin(inner: T, origin: Uri) -> Self
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TcClient<InterceptedService<T, F>>where
F: Interceptor,
T::ResponseBody: Default,
T: Service<Request<Body>, Response = Response<<T as GrpcService<Body>>::ResponseBody>>,
<T as Service<Request<Body>>>::Error: Into<StdError> + Send + Sync,
Sourcepub fn send_compressed(self, encoding: CompressionEncoding) -> Self
pub fn send_compressed(self, encoding: CompressionEncoding) -> Self
Compress requests with the given encoding.
This requires the server to support it otherwise it might respond with an error.
Sourcepub fn accept_compressed(self, encoding: CompressionEncoding) -> Self
pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self
Enable decompressing responses.
Sourcepub fn max_decoding_message_size(self, limit: usize) -> Self
pub fn max_decoding_message_size(self, limit: usize) -> Self
Limits the maximum size of a decoded message.
Default: 4MB
Sourcepub fn max_encoding_message_size(self, limit: usize) -> Self
pub fn max_encoding_message_size(self, limit: usize) -> Self
Limits the maximum size of an encoded message.
Default: usize::MAX
Sourcepub async fn new_gid(
&mut self,
request: impl IntoRequest<NewGidRequest>,
) -> Result<Response<NewGidReply>, Status>
pub async fn new_gid( &mut self, request: impl IntoRequest<NewGidRequest>, ) -> Result<Response<NewGidReply>, Status>
生成一个全局事务号。生产上更建议直接用业务单号当 gid
Sourcepub async fn prepare(
&mut self,
request: impl IntoRequest<PrepareRequest>,
) -> Result<Response<Empty>, Status>
pub async fn prepare( &mut self, request: impl IntoRequest<PrepareRequest>, ) -> Result<Response<Empty>, Status>
第一阶段:msg 建 prepared 事务 + 正向分支;tcc / xa 只建空事务
Sourcepub async fn register_branch(
&mut self,
request: impl IntoRequest<RegisterBranchRequest>,
) -> Result<Response<Empty>, Status>
pub async fn register_branch( &mut self, request: impl IntoRequest<RegisterBranchRequest>, ) -> Result<Response<Empty>, Status>
分支登记。必须先登记再做一阶段 —— 反过来的话一阶段成功但 TC 不知道 有这个分支,回滚时会漏掉它(TCC 是资源泄漏,XA 会留下永久持锁的事务)
Sourcepub async fn submit(
&mut self,
request: impl IntoRequest<SubmitRequest>,
) -> Result<Response<Empty>, Status>
pub async fn submit( &mut self, request: impl IntoRequest<SubmitRequest>, ) -> Result<Response<Empty>, Status>
提交。saga 在这里一次性给出全部步骤;tcc / msg / xa 是把 prepared 推成 submitted
Sourcepub async fn abort(
&mut self,
request: impl IntoRequest<AbortRequest>,
) -> Result<Response<Empty>, Status>
pub async fn abort( &mut self, request: impl IntoRequest<AbortRequest>, ) -> Result<Response<Empty>, Status>
主动中止,触发逆序补偿
Sourcepub async fn retry(
&mut self,
request: impl IntoRequest<RetryRequest>,
) -> Result<Response<Empty>, Status>
pub async fn retry( &mut self, request: impl IntoRequest<RetryRequest>, ) -> Result<Response<Empty>, Status>
立刻重试:把事务排到调度队首(不跳过任何安全检查)
Sourcepub async fn query(
&mut self,
request: impl IntoRequest<QueryRequest>,
) -> Result<Response<TransView>, Status>
pub async fn query( &mut self, request: impl IntoRequest<QueryRequest>, ) -> Result<Response<TransView>, Status>
查一笔事务的当前状态和各分支明细
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for TcClient<T>
impl<T> RefUnwindSafe for TcClient<T>where
T: RefUnwindSafe,
impl<T> Send for TcClient<T>where
T: Send,
impl<T> Sync for TcClient<T>where
T: Sync,
impl<T> Unpin for TcClient<T>where
T: Unpin,
impl<T> UnsafeUnpin for TcClient<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for TcClient<T>where
T: UnwindSafe,
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