@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 RuntimeTimerStreamScope | Runtime Timer Stream Scope 接口,共包含 3 个公开字段或方法。 |
RuntimeTimerSweepRequest | 接口 | interface RuntimeTimerSweepRequest | Runtime Timer Sweep Request 接口,共包含 5 个公开字段或方法。 |
RuntimeTimerSweepResult | 接口 | interface RuntimeTimerSweepResult | Runtime Timer Sweep Result 接口,共包含 7 个公开字段或方法。 |
RuntimeTimerSweepRunResult | 接口 | interface RuntimeTimerSweepRunResult | Runtime 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];