pub struct CheckpointConfig<S: WorkflowState> {
pub trigger: TriggerPolicy,
pub retention: RetentionPolicy,
/* private fields */
}Expand description
Checkpoint 保存配置 — 三层策略。
CheckpointConfig
├── trigger: 何时保存(EveryNode / BarrierOnly / Manual / OnMutation)
├── retention: 保留多少个(KeepAll / KeepLatest(N) / TimeBased)
├── save_fn: 保存回调
└── store: 存储后端引用(用于 prune)Fields§
§trigger: TriggerPolicy触发策略
retention: RetentionPolicy保留策略
Implementations§
Source§impl<S: WorkflowState> CheckpointConfig<S>
impl<S: WorkflowState> CheckpointConfig<S>
Sourcepub fn new(
save_fn: impl Fn(Checkpoint<S>, TraceId) -> Pin<Box<dyn Future<Output = Result<(), CheckpointStoreError>> + Send>> + Send + Sync + 'static,
graph_hash: u64,
) -> Self
pub fn new( save_fn: impl Fn(Checkpoint<S>, TraceId) -> Pin<Box<dyn Future<Output = Result<(), CheckpointStoreError>> + Send>> + Send + Sync + 'static, graph_hash: u64, ) -> Self
创建 CheckpointConfig。
save_fn 接收 (Checkpoint<S>, TraceId) 并异步保存。
通常由调用方组合 TypedCheckpointStore + SerdeCheckpointCodec 构造。
Sourcepub fn with_trigger(self, trigger: TriggerPolicy) -> Self
pub fn with_trigger(self, trigger: TriggerPolicy) -> Self
设置触发策略。
Sourcepub fn with_retention(self, retention: RetentionPolicy) -> Self
pub fn with_retention(self, retention: RetentionPolicy) -> Self
设置保留策略。
Sourcepub fn with_store(self, store: Arc<dyn BlobCheckpointStore>) -> Self
pub fn with_store(self, store: Arc<dyn BlobCheckpointStore>) -> Self
设置存储后端引用(用于 prune)。
Sourcepub fn with_policy(self, policy: CheckpointPolicy) -> Self
pub fn with_policy(self, policy: CheckpointPolicy) -> Self
向后兼容 — 设置旧的 CheckpointPolicy(自动转换为 TriggerPolicy)。
Sourcepub fn should_save(&self, has_mutations: bool, is_barrier: bool) -> bool
pub fn should_save(&self, has_mutations: bool, is_barrier: bool) -> bool
根据策略判断是否应该保存。
Sourcepub async fn apply_retention(
&self,
trace_id: &TraceId,
) -> Result<(), CheckpointStoreError>
pub async fn apply_retention( &self, trace_id: &TraceId, ) -> Result<(), CheckpointStoreError>
执行保留策略(prune)。
Auto Trait Implementations§
impl<S> !RefUnwindSafe for CheckpointConfig<S>
impl<S> !UnwindSafe for CheckpointConfig<S>
impl<S> Freeze for CheckpointConfig<S>
impl<S> Send for CheckpointConfig<S>
impl<S> Sync for CheckpointConfig<S>
impl<S> Unpin for CheckpointConfig<S>
impl<S> UnsafeUnpin for CheckpointConfig<S>
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