Skip to main content

TypedCheckpointStore

Struct TypedCheckpointStore 

Source
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,

Source

pub fn new(store: &'a dyn BlobCheckpointStore, codec: Codec) -> Self

Source§

impl<'a, Codec, S> TypedCheckpointStore<'a, Codec, S>
where S: WorkflowState + Serialize + for<'de> Deserialize<'de>, Codec: CheckpointCodec<S>,

Source

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。

Source

pub async fn load( &self, id: &CheckpointId, expected_hash: u64, ) -> Result<Option<Checkpoint<S>>, CheckpointStoreError>

加载指定 ID 的 Checkpoint。

校验 graph_hash:不匹配则返回 GraphMismatch 错误。

Source

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>
where Codec: Unpin, S: Unpin,

§

impl<'a, Codec, S> UnsafeUnpin for TypedCheckpointStore<'a, Codec, S>
where Codec: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more