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,
state: &mut State,
) -> Result<NextStep, GraphError>
pub fn apply_decision( &self, decision: BarrierDecision, state: &mut State, ) -> Result<NextStep, GraphError>
处理决策结果 — 写入 State 并返回 NextStep。
由 executor 在收到外部决策后调用。
Trait Implementations§
Source§impl GraphNode for BarrierNode
impl GraphNode for BarrierNode
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
_state: &'life1 mut State,
) -> Pin<Box<dyn Future<Output = Result<NextStep, GraphError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
_state: &'life1 mut State,
) -> Pin<Box<dyn Future<Output = Result<NextStep, 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 mut 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 mut 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,
流式执行 — 返回 BarrierPaused,由 executor 发射事件并等待决策。
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