Skip to content

@codesoul-co/hypha-core / contracts/runtime-timer

模块用法

用于声明并运行时校验契约。Runtime timer 模块公开 1 常量、4 接口、1 类型。

从包入口导入

ts
import {
  RUNTIME_TIMER_SWEEP_DISPOSITIONS,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeTimerStreamScope,
  RuntimeTimerSweepRequest,
  RuntimeTimerSweepResult,
  RuntimeTimerSweepRunResult,
  RuntimeTimerSweepDisposition,
} from '@codesoul-co/hypha-core';

使用要点

  • 5 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

公共导出

Symbol种类签名说明
RUNTIME_TIMER_SWEEP_DISPOSITIONS常量const RUNTIME_TIMER_SWEEP_DISPOSITIONS: readonly ["fired", "not_due", "lease_unavailable", "already_resolved"]contracts/runtime-timer 模块导出的 RUNTIME TIMER SWEEP DISPOSITIONS 常量。
RuntimeTimerStreamScope接口interface RuntimeTimerStreamScopeRuntime Timer Stream Scope 接口,共包含 3 个公开字段或方法。
RuntimeTimerSweepRequest接口interface RuntimeTimerSweepRequestRuntime Timer Sweep Request 接口,共包含 5 个公开字段或方法。
RuntimeTimerSweepResult接口interface RuntimeTimerSweepResultRuntime Timer Sweep Result 接口,共包含 7 个公开字段或方法。
RuntimeTimerSweepRunResult接口interface RuntimeTimerSweepRunResultRuntime Timer Sweep Run Result 接口,共包含 3 个公开字段或方法。
RuntimeTimerSweepDisposition类型type RuntimeTimerSweepDisposition = (typeof RUNTIME_TIMER_SWEEP_DISPOSITIONS)[number]Runtime Timer Sweep Disposition 公共类型别名;完整类型表达式见声明。

RUNTIME_TIMER_SWEEP_DISPOSITIONS

contracts/runtime-timer 模块导出的 RUNTIME TIMER SWEEP DISPOSITIONS 常量。

  • 种类: 常量
  • 导入: import { RUNTIME_TIMER_SWEEP_DISPOSITIONS } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-timer

声明

text
export declare const RUNTIME_TIMER_SWEEP_DISPOSITIONS: readonly ["fired", "not_due", "lease_unavailable", "already_resolved"];

RuntimeTimerStreamScope

Runtime Timer Stream Scope 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeTimerStreamScope } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-timer

声明

text
export interface RuntimeTimerStreamScope {
    tenantId?: string;
    userId: string;
    runId: string;
}

契约成员

成员种类签名说明
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
tenantId属性tenantId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeTimerSweepRequest

Runtime Timer Sweep Request 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeTimerSweepRequest } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-timer

声明

text
export interface RuntimeTimerSweepRequest {
    ownerId: string;
    leaseTtlMs: number;
    limit: number;
    cursor?: string;
    firedAt: string;
}

契约成员

成员种类签名说明
cursor属性cursor?: string公开属性;类型、只读和可选状态以签名列为准。
firedAt属性firedAt: string公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
limit属性limit: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeTimerSweepResult

Runtime Timer Sweep Result 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeTimerSweepResult } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-timer

声明

text
export interface RuntimeTimerSweepResult {
    scanned: number;
    fired: number;
    notDue: number;
    leaseUnavailable: number;
    alreadyResolved: number;
    results: RuntimeTimerSweepRunResult[];
    nextCursor?: string;
}

契约成员

成员种类签名说明
alreadyResolved属性alreadyResolved: number公开属性;类型、只读和可选状态以签名列为准。
fired属性fired: number公开属性;类型、只读和可选状态以签名列为准。
leaseUnavailable属性leaseUnavailable: number公开属性;类型、只读和可选状态以签名列为准。
nextCursor属性nextCursor?: string公开属性;类型、只读和可选状态以签名列为准。
notDue属性notDue: number公开属性;类型、只读和可选状态以签名列为准。
results属性results: RuntimeTimerSweepRunResult[]公开属性;类型、只读和可选状态以签名列为准。
scanned属性scanned: number公开属性;类型、只读和可选状态以签名列为准。

RuntimeTimerSweepRunResult

Runtime Timer Sweep Run Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeTimerSweepRunResult } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-timer

声明

text
export interface RuntimeTimerSweepRunResult {
    scope: RuntimeTimerStreamScope;
    disposition: RuntimeTimerSweepDisposition;
    eventIds: string[];
}

契约成员

成员种类签名说明
disposition属性disposition: "lease_unavailable" | "fired" | "not_due" | "already_resolved"公开属性;类型、只读和可选状态以签名列为准。
eventIds属性eventIds: string[]公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeTimerStreamScope公开属性;类型、只读和可选状态以签名列为准。

RuntimeTimerSweepDisposition

Runtime Timer Sweep Disposition 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { RuntimeTimerSweepDisposition } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-timer

声明

text
export type RuntimeTimerSweepDisposition = (typeof RUNTIME_TIMER_SWEEP_DISPOSITIONS)[number];