pub struct Store { /* private fields */ }Expand description
存储层的统一入口。按 URL 前缀自动选后端:
sqlite:... / postgres://... / mysql://... → SQL 后端
redis://... / rediss://... → Redis 后端(要开 redis feature)⚠ Redis 后端跟 SQL 后端有实打实的语义差异(持久性更弱、终态会过期),
用之前务必读 [redis_store] 的模块说明。
Implementations§
Source§impl Store
impl Store
pub async fn create_token( &self, hash: &str, name: &str, secret: &str, ) -> Result<()>
pub async fn list_tokens(&self) -> Result<Vec<TokenRow>>
pub async fn revoke_token(&self, hash: &str) -> Result<bool>
pub async fn active_token_hashes(&self) -> Result<Vec<String>>
pub async fn touch_token(&self, hash: &str, ip: &str) -> Result<()>
Source§impl Store
impl Store
Sourcepub async fn create_global(
&self,
g: &GlobalRow,
branches: &[BranchRow],
) -> Result<bool>
pub async fn create_global( &self, g: &GlobalRow, branches: &[BranchRow], ) -> Result<bool>
建全局事务 + 分支。已存在返回 false,不覆盖
pub async fn get_global(&self, gid: &str) -> Result<Option<GlobalRow>>
pub async fn list_branches(&self, gid: &str) -> Result<Vec<BranchRow>>
Sourcepub async fn lock_one_due(
&self,
owner: &str,
lease: i64,
) -> Result<Option<GlobalRow>>
pub async fn lock_one_due( &self, owner: &str, lease: i64, ) -> Result<Option<GlobalRow>>
抢一个到期事务。多实例不重复推进就靠它的原子性
pub async fn set_global_status( &self, gid: &str, status: GlobalStatus, trans_type: TransType, reason: &str, ) -> Result<()>
Sourcepub async fn submit_prepared(
&self,
gid: &str,
owner: &str,
next_cron_time: i64,
) -> Result<SubmitOutcome>
pub async fn submit_prepared( &self, gid: &str, owner: &str, next_cron_time: i64, ) -> Result<SubmitOutcome>
把 prepared 推成 submitted 并排进调度队列,一次调用做完。见 SubmitOutcome
pub async fn set_branch_result( &self, gid: &str, branch_id: &str, op: BranchOp, status: BranchStatus, payload: &str, ) -> Result<()>
pub async fn set_branch_status( &self, gid: &str, branch_id: &str, op: BranchOp, status: BranchStatus, ) -> Result<()>
pub async fn schedule_retry(&self, gid: &str, interval: i64) -> Result<()>
pub async fn schedule_now(&self, gid: &str) -> Result<()>
pub async fn register_branch( &self, gid: &str, branch_id: &str, ops: &[(BranchOp, String)], ) -> Result<()>
pub async fn list_recent(&self, limit: i64) -> Result<Vec<GlobalRow>>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Store
impl !UnwindSafe for Store
impl Freeze for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
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 more