Skip to main content

DefinitionRegistry

Struct DefinitionRegistry 

Source
pub struct DefinitionRegistry { /* private fields */ }
Expand description

业务作用:持有本进程可驱动的全部 workflow definition,按 (名称, 定义版本) 索引。

注册表只在启动阶段构建(register 全部完成后再交给 Orchestrator),运行期只读, 因此无内部锁;定义演进并存表示同名 workflow 注册多个版本。

Implementations§

Source§

impl DefinitionRegistry

Source

pub fn new() -> Self

业务作用:创建空注册表。

参数说明: 无。

返回:不含任何 definition 的注册表。

Source

pub fn is_empty(&self) -> bool

业务作用:判断当前快照是否没有任何流程定义,供动态 Catalog 空启动与静态模式门禁区分。

参数说明: 无。

返回:没有已注册定义时返回真。

Source

pub fn len(&self) -> usize

业务作用:读取当前不可变快照中的定义数量,供启动报告与 Catalog generation 核对。

参数说明: 无。

返回:按 (workflow, definition_version) 去重后的定义数量。

Source

pub fn definitions(&self) -> impl Iterator<Item = &WorkflowDefinition>

业务作用:按稳定键顺序遍历当前快照的全部流程定义,供发布器生成完整 definition seal。

参数说明: 无。

返回:以 workflow 名称、定义版本排序的定义迭代器。

Source

pub fn definitions_with_tenants( &self, ) -> impl Iterator<Item = (Option<&str>, &WorkflowDefinition)>

业务作用:连同可选租户作用域遍历全部定义,供动态 capability 路由保持租户边界。

参数说明: 无。

返回:静态全局定义的租户为空,动态 Catalog 定义携带其规范租户。

Source

pub fn register(&mut self, definition: WorkflowDefinition) -> Result<()>

业务作用:注册一个已通过构造预检的 definition,同一版本重复注册按摘要裁决。

参数说明:

  • definition: 待注册的流程定义。

返回:解决模式已具备 hosted 闭环且新增或摘要一致时返回 Ok;Callback/Manual 或同 (workflow, version) 摘要不一致返回错误,不允许带不完整合同启动。

Source

pub fn register_for_tenant( &mut self, tenant: TenantId, definition: WorkflowDefinition, accepts_new: bool, ) -> Result<()>

业务作用:为一个租户登记 active 或 deprecated definition,使新实例门禁与在途实例装载分离。

参数说明:

  • tenant:定义适用的租户身份。
  • definition:已经通过构造校验的不可变流程。
  • accepts_new:active 为真,deprecated 为假。

返回:首次登记或同键同摘要同状态时成功;任何原地内容或生命周期漂移返回错误。

Source

pub fn get( &self, workflow: &WorkflowName, version: DefinitionVersion, ) -> Option<&WorkflowDefinition>

业务作用:按名称与定义版本查找 definition,供推进裁决使用实例固定的内容。

参数说明:

  • workflow: workflow 名称。
  • version: definition 版本。

返回:存在返回定义引用;不存在返回 None。

Source

pub fn get_for_tenant( &self, tenant: &TenantId, workflow: &WorkflowName, version: DefinitionVersion, ) -> Option<&WorkflowDefinition>

业务作用:按租户优先读取运行期 definition,并为静态全租户定义保留兼容回退。

参数说明:

  • tenant:需要解析定义的租户身份。
  • workflow:实例绑定的工作流名。
  • version:实例绑定的业务定义版本。

返回:存在租户条目时返回其定义,不按 accepts_new 过滤;否则回退 get 的全局定义,均不存在时 None。只读注册表,不验证摘要。

Source

pub fn get_for_start( &self, tenant: &TenantId, workflow: &WorkflowName, version: DefinitionVersion, ) -> Option<&WorkflowDefinition>

业务作用:只返回当前允许创建新实例的租户 definition,deprecated 合同仍可供旧实例收敛。

参数说明:

  • tenant:需要解析定义的租户身份。
  • workflow:实例绑定的工作流名。
  • version:实例绑定的业务定义版本。

返回:存在租户条目时仅在 accepts_new 为 true 返回定义,拒绝时不回退全局;无租户条目才按全局 accepts_new 选择,未知或不接受新实例时 None。

Source

pub async fn verify_non_terminal<S>( &self, store: &S, scan_limit: u32, ) -> Result<()>

业务作用:启动预检——校验全部非终态实例引用的 definition 可用且摘要一致。 缺失或摘要漂移时必须拒绝 Ready 而不是带病启动:用新内容驱动旧实例会让补偿 顺序、身份派生与冻结计划全部失真。

参数说明:

  • store:用于分页读取非终态实例的持久化后端。
  • scan_limit:单次扫描的实例条数上限,须由调用方确保非零且后端支持。

返回:本次分页扫描遇到的实例定义都存在且摘要一致时成功;缺失或漂移返回聚合计数,读取失败原样传播 store 错误。不建立跨页一致快照,scan_limit 本层不校验非零。

Trait Implementations§

Source§

impl Clone for DefinitionRegistry

Source§

fn clone(&self) -> Self

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 DefinitionRegistry

Source§

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

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

impl Default for DefinitionRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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