Skip to content

Commit

Permalink
Expose get_timestamp (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu authored Jun 19, 2023
1 parent 3f1ec8e commit e10074d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/transaction/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ impl<PdC: PdClient> Transaction<PdC> {
.await
}

pub fn get_read_timestamp(&self) -> Timestamp {
self.timestamp.clone()
}

pub async fn get_current_timestamp(&mut self) -> Result<Timestamp> {
self.check_allow_operation().await?;
let rpc = self.rpc.clone();

// Convert to the timestamp to bytes.
let r = rpc.get_timestamp().await;
match r {
Ok(ts) => {
Ok(ts)
},
Err(e) => Err(e),
}
}

/// Create a `get for update` request.
///
/// The request reads and "locks" a key. It is similar to `SELECT ... FOR
Expand Down

0 comments on commit e10074d

Please sign in to comment.