pub struct WriteHandle {
txn_id: TxnId,
tx: Sender,
txn_state: TxnState,
}
Expand description
WriteHandle
writes its data into a table in a transactional way.
First, it needs to call begin()
and then write chunks by calling write_chunk()
.
Finally call end()
to commit the transaction or rollback()
to rollback the transaction.
If the WriteHandle
is dropped with a Begin
transaction state, it will automatically
rollback the transaction.
Fields§
§txn_id: TxnId
§tx: Sender
§txn_state: TxnState
Implementations§
source§impl WriteHandle
impl WriteHandle
pub fn new(txn_id: TxnId, tx: Sender) -> Self
pub fn begin(&mut self) -> Result<()>
pub async fn write_chunk(&self, chunk: StreamChunk) -> Result<()>
pub async fn end(self) -> Result<()>
pub fn rollback(self) -> Result<Receiver<usize>>
fn rollback_inner(&mut self) -> Result<Receiver<usize>>
sourceasync fn write_txn_data_msg(&self, txn_msg: TxnMsg) -> Result<Receiver<usize>>
async fn write_txn_data_msg(&self, txn_msg: TxnMsg) -> Result<Receiver<usize>>
Asynchronously write txn messages into table. Changes written here will be simply passed to the associated streaming task via channel, and then be materialized to storage there.
Returns an oneshot channel which will be notified when the chunk is taken by some reader,
and the usize
represents the cardinality of this chunk.
sourcefn write_txn_control_msg(&self, txn_msg: TxnMsg) -> Result<Receiver<usize>>
fn write_txn_control_msg(&self, txn_msg: TxnMsg) -> Result<Receiver<usize>>
Same as the write_txn_data_msg
, but it is not an async function and send control message
without permit acquiring.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WriteHandle
impl !RefUnwindSafe for WriteHandle
impl Send for WriteHandle
impl Sync for WriteHandle
impl Unpin for WriteHandle
impl !UnwindSafe for WriteHandle
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.