Skip to main content

BarrierNode

Struct BarrierNode 

Source
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 审批节点。

执行流程:

  1. 返回 StreamNodeResult::BarrierPaused,executor 发射 BarrierPaused 事件
  2. 消费者通过 GraphHandle::decide(barrier_id, decision) 提交决策
  3. 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

Source

pub fn new(name: impl Into<String>) -> Self

Source

pub fn timeout(self, timeout: Duration) -> Self

设置超时时间。超时后按 default_action 处理。

Source

pub fn default_action(self, action: BarrierDefaultAction) -> Self

设置超时默认行为(默认 Reject)。

Source

pub fn reject_key(self, key: impl Into<String>) -> Self

设置拒绝原因写入 State 的 key(默认 “{name}.reject_reason”)。

Source

pub fn approve_key(self, key: impl Into<String>) -> Self

设置审批标记写入 State 的 key(默认 “{name}.approved”)。

Source

pub fn apply_decision( &self, decision: BarrierDecision, ) -> (NextStep, Vec<StateDelta>)

处理决策结果 — 返回 NextStep + StateDelta,不直接修改 State。

由 executor 在收到外部决策后调用。Executor 负责 apply deltas。

Trait Implementations§

Source§

impl Clone for BarrierNode

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for BarrierNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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,

阻塞模式不支持 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,

流式执行 — 返回 Pause,由 executor 发射事件并等待决策。

Source§

fn metadata_hint(&self) -> NodeMetadata

节点元数据提示 — 静态声明节点的执行特征。 Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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