pub struct WorkflowContext {Show 13 fields
pub instance_id: String,
pub workflow_id: String,
pub status: WorkflowStatus,
pub current_node_id: Option<String>,
pub inputs: HashMap<String, Value>,
pub variables: HashMap<String, Value>,
pub node_executions: HashMap<String, NodeExecution>,
pub execution_path: Vec<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub started_at: Option<DateTime<Utc>>,
pub finished_at: Option<DateTime<Utc>>,
pub error: Option<String>,
}Expand description
工作流上下文
Fields§
§instance_id: String工作流实例ID
workflow_id: String工作流定义ID
status: WorkflowStatus当前状态
current_node_id: Option<String>当前节点ID
inputs: HashMap<String, Value>输入参数
variables: HashMap<String, Value>变量存储
node_executions: HashMap<String, NodeExecution>节点执行记录
execution_path: Vec<String>执行历史(节点ID顺序)
created_at: DateTime<Utc>创建时间
updated_at: DateTime<Utc>更新时间
started_at: Option<DateTime<Utc>>开始时间
finished_at: Option<DateTime<Utc>>结束时间
error: Option<String>错误信息
Implementations§
Source§impl WorkflowContext
impl WorkflowContext
Sourcepub fn set_variable(&mut self, key: String, value: Value)
pub fn set_variable(&mut self, key: String, value: Value)
设置变量
Sourcepub fn get_variable(&self, key: &str) -> Option<&Value>
pub fn get_variable(&self, key: &str) -> Option<&Value>
获取变量
Sourcepub fn set_current_node(&mut self, node_id: String)
pub fn set_current_node(&mut self, node_id: String)
设置当前节点
Sourcepub fn get_or_create_node_execution(
&mut self,
node_id: &str,
) -> &mut NodeExecution
pub fn get_or_create_node_execution( &mut self, node_id: &str, ) -> &mut NodeExecution
获取或创建节点执行记录
Sourcepub fn get_node_execution(&self, node_id: &str) -> Option<&NodeExecution>
pub fn get_node_execution(&self, node_id: &str) -> Option<&NodeExecution>
获取节点执行记录
Sourcepub fn total_duration_ms(&self) -> Option<i64>
pub fn total_duration_ms(&self) -> Option<i64>
获取总执行时长(毫秒)
Sourcepub fn can_continue(&self) -> bool
pub fn can_continue(&self) -> bool
检查是否可以继续执行
Trait Implementations§
Source§impl Clone for WorkflowContext
impl Clone for WorkflowContext
Source§fn clone(&self) -> WorkflowContext
fn clone(&self) -> WorkflowContext
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 WorkflowContext
impl Debug for WorkflowContext
Source§impl<'de> Deserialize<'de> for WorkflowContext
impl<'de> Deserialize<'de> for WorkflowContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for WorkflowContext
impl RefUnwindSafe for WorkflowContext
impl Send for WorkflowContext
impl Sync for WorkflowContext
impl Unpin for WorkflowContext
impl UnsafeUnpin for WorkflowContext
impl UnwindSafe for WorkflowContext
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