pub struct BarrierNode {
pub name: String,
pub timeout: Option<Duration>,
pub default_action: BarrierDefaultAction,
pub reject_key: String,
pub approve_key: String,
}Expand description
Human-in-the-loop 审批节点。
执行流程:
- 返回
StreamNodeResult::BarrierPaused,executor 发射BarrierPaused事件 - 消费者通过
GraphHandle::decide(barrier_id, decision)提交决策 - executor 的
wait_barrier_decision()接收决策,调用apply_decision()应用
阻塞模式不支持。 调用 execute() 直接报错,引导使用 execute_stream()。
Fields§
§name: String§timeout: Option<Duration>超时时间(None = 无限等待)
default_action: BarrierDefaultAction超时默认行为
reject_key: String拒绝原因写入 State 的 key 后缀(默认 “{name}.reject_reason”)
approve_key: String审批通过后写入 State 的标记 key(默认 “{name}.approved”)
Implementations§
Source§impl BarrierNode
impl BarrierNode
pub fn new(name: impl Into<String>) -> Self
Sourcepub fn default_action(self, action: BarrierDefaultAction) -> Self
pub fn default_action(self, action: BarrierDefaultAction) -> Self
设置超时默认行为(默认 Reject)。
Sourcepub fn reject_key(self, key: impl Into<String>) -> Self
pub fn reject_key(self, key: impl Into<String>) -> Self
设置拒绝原因写入 State 的 key(默认 “{name}.reject_reason”)。
Sourcepub fn approve_key(self, key: impl Into<String>) -> Self
pub fn approve_key(self, key: impl Into<String>) -> Self
设置审批标记写入 State 的 key(默认 “{name}.approved”)。
Sourcepub fn apply_decision(
&self,
decision: BarrierDecision,
) -> (NextStep, Vec<StateDelta>)
pub fn apply_decision( &self, decision: BarrierDecision, ) -> (NextStep, Vec<StateDelta>)
处理决策结果 — 返回 NextStep + StateDelta,不直接修改 State。
由 executor 在收到外部决策后调用。Executor 负责 apply deltas。
Trait Implementations§
Source§impl Clone for BarrierNode
impl Clone for BarrierNode
Source§fn clone(&self) -> BarrierNode
fn clone(&self) -> BarrierNode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BarrierNode
impl Debug for BarrierNode
Source§impl FlowNode for BarrierNode
impl FlowNode for BarrierNode
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
_state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
_state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
阻塞模式不支持 BarrierNode — 直接报错。
Source§fn execute_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_state: &'life1 State,
_sink: &'life2 Sender<GraphEvent>,
span_id: SpanId,
) -> Pin<Box<dyn Future<Output = Result<StreamNodeResult, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_state: &'life1 State,
_sink: &'life2 Sender<GraphEvent>,
span_id: SpanId,
) -> Pin<Box<dyn Future<Output = Result<StreamNodeResult, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
流式执行 — 返回 Pause,由 executor 发射事件并等待决策。
Source§fn metadata_hint(&self) -> NodeMetadata
fn metadata_hint(&self) -> NodeMetadata
节点元数据提示 — 静态声明节点的执行特征。 Read more
Auto Trait Implementations§
impl Freeze for BarrierNode
impl RefUnwindSafe for BarrierNode
impl Send for BarrierNode
impl Sync for BarrierNode
impl Unpin for BarrierNode
impl UnsafeUnpin for BarrierNode
impl UnwindSafe for BarrierNode
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