pub struct TypedCheckpointStore<'a, Codec, S: WorkflowState = State> { /* private fields */ }Expand description
类型化 Checkpoint 存储 — Codec + BlobStore 的组合。
将 Checkpoint<S> 的保存/加载委托给 Codec 进行序列化,
再通过 BlobCheckpointStore 进行持久化。
§示例
ⓘ
let store = InMemoryBlobStore::new();
let codec = SerdeCheckpointCodec::<State>::new();
let typed = TypedCheckpointStore::new(&store, codec);
typed.save_with_trace(&trace_id, &checkpoint, graph_hash).await?;
let restored = typed.load(&id, graph_hash).await?;Implementations§
Source§impl<'a, Codec, S> TypedCheckpointStore<'a, Codec, S>where
S: WorkflowState,
impl<'a, Codec, S> TypedCheckpointStore<'a, Codec, S>where
S: WorkflowState,
pub fn new(store: &'a dyn BlobCheckpointStore, codec: Codec) -> Self
Source§impl<'a, Codec, S> TypedCheckpointStore<'a, Codec, S>
impl<'a, Codec, S> TypedCheckpointStore<'a, Codec, S>
Sourcepub async fn save_with_trace(
&self,
trace_id: &TraceId,
checkpoint: &Checkpoint<S>,
graph_hash: u64,
) -> Result<(), CheckpointStoreError>
pub async fn save_with_trace( &self, trace_id: &TraceId, checkpoint: &Checkpoint<S>, graph_hash: u64, ) -> Result<(), CheckpointStoreError>
保存 Checkpoint 并关联 trace_id。
graph_hash 由调用方提供(从 Graph::hash_u64() 获取),
写入 Blob 作为 correctness invariant。
Sourcepub async fn load(
&self,
id: &CheckpointId,
expected_hash: u64,
) -> Result<Option<Checkpoint<S>>, CheckpointStoreError>
pub async fn load( &self, id: &CheckpointId, expected_hash: u64, ) -> Result<Option<Checkpoint<S>>, CheckpointStoreError>
加载指定 ID 的 Checkpoint。
校验 graph_hash:不匹配则返回 GraphMismatch 错误。
Sourcepub async fn load_latest(
&self,
trace_id: &TraceId,
expected_hash: u64,
) -> Result<Option<Checkpoint<S>>, CheckpointStoreError>
pub async fn load_latest( &self, trace_id: &TraceId, expected_hash: u64, ) -> Result<Option<Checkpoint<S>>, CheckpointStoreError>
加载 trace 最新的 Checkpoint。
校验 graph_hash:不匹配则返回 GraphMismatch 错误。
Auto Trait Implementations§
impl<'a, Codec, S = State> !RefUnwindSafe for TypedCheckpointStore<'a, Codec, S>
impl<'a, Codec, S = State> !UnwindSafe for TypedCheckpointStore<'a, Codec, S>
impl<'a, Codec, S> Freeze for TypedCheckpointStore<'a, Codec, S>where
Codec: Freeze,
impl<'a, Codec, S> Send for TypedCheckpointStore<'a, Codec, S>where
Codec: Send,
impl<'a, Codec, S> Sync for TypedCheckpointStore<'a, Codec, S>where
Codec: Sync,
impl<'a, Codec, S> Unpin for TypedCheckpointStore<'a, Codec, S>
impl<'a, Codec, S> UnsafeUnpin for TypedCheckpointStore<'a, Codec, S>where
Codec: UnsafeUnpin,
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