Skip to content

@codesoul-co/hypha-core / modules/runtime/runtime-activity-redispatch-service

模块用法

用于执行该边界的运行时行为。Runtime activity redispatch service 模块公开 1 类、1 函数、6 接口、1 类型。

从包入口导入

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

import type {
  RuntimeActivityRedispatchAttempt,
  RuntimeActivityRedispatchCommand,
  RuntimeActivityRedispatchPort,
  RuntimeActivityRedispatchResult,
  RuntimeActivityRedispatchServiceOptions,
  RuntimeActivityRevisionValidator,
  RuntimeActivityRedispatchReconciliation,
} from '@codesoul-co/hypha-core';

使用要点

  • 7 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 1 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。

公共导出

Symbol种类签名说明
RuntimeActivityRedispatchServicenew RuntimeActivityRedispatchService(options: RuntimeActivityRedispatchServiceOptions): RuntimeActivityRedispatchServiceRevalidates approved HumanTask evidence, records redispatch intent, invokes an Owner-provided idempotent Activity dispatcher, and persists acceptance. An intent without a receipt is reconciled before any retry is dispatched.
runtimeActivityRedispatchIdentity函数runtimeActivityRedispatchIdentity(command: Pick<RuntimeActivityRedispatchCommand, "scope" | "taskId" | "expectedTaskRevision">): stringRuntime Activity Redispatch Identity 函数,提供 1 个公开调用签名;参数与返回类型见下表。
RuntimeActivityRedispatchAttempt接口interface RuntimeActivityRedispatchAttemptRuntime Activity Redispatch Attempt 接口,共包含 9 个公开字段或方法。
RuntimeActivityRedispatchCommand接口interface RuntimeActivityRedispatchCommand extends RuntimeActivityDescriptorReferenceRuntime Activity Redispatch Command 接口,共包含 12 个公开字段或方法。
RuntimeActivityRedispatchPort接口interface RuntimeActivityRedispatchPortRuntime Activity Redispatch Port 接口,共包含 2 个公开字段或方法。
RuntimeActivityRedispatchResult接口interface RuntimeActivityRedispatchResultRuntime Activity Redispatch Result 接口,共包含 8 个公开字段或方法。
RuntimeActivityRedispatchServiceOptions接口interface RuntimeActivityRedispatchServiceOptionsRuntime Activity Redispatch Service Options 接口,共包含 12 个公开字段或方法。
RuntimeActivityRevisionValidator接口interface RuntimeActivityRevisionValidatorRuntime Activity Revision Validator 接口,共包含 1 个公开字段或方法。
RuntimeActivityRedispatchReconciliation类型type RuntimeActivityRedispatchReconciliation = { status: 'accepted'; commandId: string; } | { status: 'safe_to_dispatch'; } | { status: 'unknown'; reason: string; }Runtime Activity Redispatch Reconciliation 公共类型别名;完整类型表达式见声明。

RuntimeActivityRedispatchService

Revalidates approved HumanTask evidence, records redispatch intent, invokes an Owner-provided idempotent Activity dispatcher, and persists acceptance. An intent without a receipt is reconciled before any retry is dispatched.

声明

text
export declare class RuntimeActivityRedispatchService {
    constructor(options: RuntimeActivityRedispatchServiceOptions);
    redispatch(command: RuntimeActivityRedispatchCommand): Promise<RuntimeActivityRedispatchResult>;
}

公开成员

成员种类签名说明
constructor构造函数(options: RuntimeActivityRedispatchServiceOptions): RuntimeActivityRedispatchService创建该类的实例。
redispatch方法redispatch(command: RuntimeActivityRedispatchCommand): Promise<RuntimeActivityRedispatchResult>公开方法;参数与返回类型以签名列为准。

runtimeActivityRedispatchIdentity

Runtime Activity Redispatch Identity 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function runtimeActivityRedispatchIdentity(command: Pick<RuntimeActivityRedispatchCommand, 'scope' | 'taskId' | 'expectedTaskRevision'>): string;

调用签名

text
runtimeActivityRedispatchIdentity(command: Pick<RuntimeActivityRedispatchCommand, "scope" | "taskId" | "expectedTaskRevision">): string

参数

参数类型必需说明
commandPick<RuntimeActivityRedispatchCommand, "scope" | "taskId" | "expectedTaskRevision">必需参数;接受的值由类型列定义。

返回值

  • 类型: string
  • 说明: 返回值契约由上述类型定义。

RuntimeActivityRedispatchAttempt

Runtime Activity Redispatch Attempt 接口,共包含 9 个公开字段或方法。

声明

text
export interface RuntimeActivityRedispatchAttempt {
    scope: Readonly<RuntimeScope>;
    task: Readonly<RuntimeHumanTask>;
    descriptor: Readonly<RuntimeActivityDescriptor>;
    redispatchCommandId: string;
    redispatchIdempotencyKey: string;
    approvalEventId: string;
    requestEventId: string;
    fencingToken: number;
    signal: AbortSignal;
}

契约成员

成员种类签名说明
approvalEventId属性approvalEventId: string公开属性;类型、只读和可选状态以签名列为准。
descriptor属性descriptor: Readonly<RuntimeActivityDescriptor>公开属性;类型、只读和可选状态以签名列为准。
fencingToken属性fencingToken: number公开属性;类型、只读和可选状态以签名列为准。
redispatchCommandId属性redispatchCommandId: string公开属性;类型、只读和可选状态以签名列为准。
redispatchIdempotencyKey属性redispatchIdempotencyKey: string公开属性;类型、只读和可选状态以签名列为准。
requestEventId属性requestEventId: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: Readonly<RuntimeScope>公开属性;类型、只读和可选状态以签名列为准。
signal属性signal: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
task属性task: Readonly<RuntimeHumanTask>公开属性;类型、只读和可选状态以签名列为准。

RuntimeActivityRedispatchCommand

Runtime Activity Redispatch Command 接口,共包含 12 个公开字段或方法。

声明

text
export interface RuntimeActivityRedispatchCommand extends RuntimeActivityDescriptorReference {
    commandId: string;
    scope: RuntimeScope;
    ownerId: string;
    leaseTtlMs: number;
    taskId: string;
    expectedTaskRevision: number;
    expectedSubjectHash: string;
    requestedAt: string;
    idempotencyKey?: string;
    signal?: AbortSignal;
}

契约成员

成员种类签名说明
activityDescriptorHash属性activityDescriptorHash: string公开属性;类型、只读和可选状态以签名列为准。
activityDescriptorRef属性activityDescriptorRef: string公开属性;类型、只读和可选状态以签名列为准。
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
expectedSubjectHash属性expectedSubjectHash: string公开属性;类型、只读和可选状态以签名列为准。
expectedTaskRevision属性expectedTaskRevision: number公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
signal属性signal?: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
taskId属性taskId: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeActivityRedispatchPort

Runtime Activity Redispatch Port 接口,共包含 2 个公开字段或方法。

声明

text
export interface RuntimeActivityRedispatchPort {
    dispatch(input: RuntimeActivityRedispatchAttempt): Promise<{
        commandId: string;
        reused: boolean;
    }>;
    /**
     * Resolves the crash window between an accepted external dispatch and its
     * durable Runtime receipt. `safe_to_dispatch` is an authoritative absence
     * result; uncertainty must be returned as `unknown`.
     */
    reconcile(input: RuntimeActivityRedispatchAttempt): Promise<RuntimeActivityRedispatchReconciliation>;
}

契约成员

成员种类签名说明
dispatch方法dispatch(input: RuntimeActivityRedispatchAttempt): Promise<{ commandId: string; reused: boolean; }>公开方法;参数与返回类型以签名列为准。
reconcile方法reconcile(input: RuntimeActivityRedispatchAttempt): Promise<RuntimeActivityRedispatchReconciliation>Resolves the crash window between an accepted external dispatch and its durable Runtime receipt. safe_to_dispatch is an authoritative absence result; uncertainty must be returned as unknown.

RuntimeActivityRedispatchResult

Runtime Activity Redispatch Result 接口,共包含 8 个公开字段或方法。

声明

text
export interface RuntimeActivityRedispatchResult {
    commandId: string;
    requestEventId: string;
    receiptEventId: string;
    activityCommandId: string;
    eventReused: boolean;
    receiptReused: boolean;
    commandReused: boolean;
    reconciled: boolean;
}

契约成员

成员种类签名说明
activityCommandId属性activityCommandId: string公开属性;类型、只读和可选状态以签名列为准。
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
commandReused属性commandReused: boolean公开属性;类型、只读和可选状态以签名列为准。
eventReused属性eventReused: boolean公开属性;类型、只读和可选状态以签名列为准。
receiptEventId属性receiptEventId: string公开属性;类型、只读和可选状态以签名列为准。
receiptReused属性receiptReused: boolean公开属性;类型、只读和可选状态以签名列为准。
reconciled属性reconciled: boolean公开属性;类型、只读和可选状态以签名列为准。
requestEventId属性requestEventId: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeActivityRedispatchServiceOptions

Runtime Activity Redispatch Service Options 接口,共包含 12 个公开字段或方法。

声明

text
export interface RuntimeActivityRedispatchServiceOptions {
    events: EventRuntime;
    runLeases: RunLeaseStore;
    descriptors: RuntimeActivityDescriptorStore;
    revisions: RuntimeActivityRevisionValidator;
    dispatcher: RuntimeActivityRedispatchPort;
    renewalIntervalMs?: number;
    wait?: (delayMs: number, signal: AbortSignal) => Promise<void>;
    onLeaseRenewalFailure?: (error: unknown, commandId: string) => void;
    operationalTelemetry?: RuntimeOperationalTelemetry;
    monotonicNow?: () => number;
    nextId?: (namespace: string) => string;
    now?: () => string;
}

契约成员

成员种类签名说明
descriptors属性descriptors: RuntimeActivityDescriptorStore公开属性;类型、只读和可选状态以签名列为准。
dispatcher属性dispatcher: RuntimeActivityRedispatchPort公开属性;类型、只读和可选状态以签名列为准。
events属性events: EventRuntime公开属性;类型、只读和可选状态以签名列为准。
monotonicNow方法monotonicNow?(): number公开方法;参数与返回类型以签名列为准。
nextId方法nextId?(namespace: string): string公开方法;参数与返回类型以签名列为准。
now方法now?(): string公开方法;参数与返回类型以签名列为准。
onLeaseRenewalFailure方法onLeaseRenewalFailure?(error: unknown, commandId: string): void公开方法;参数与返回类型以签名列为准。
operationalTelemetry属性operationalTelemetry?: RuntimeOperationalTelemetry公开属性;类型、只读和可选状态以签名列为准。
renewalIntervalMs属性renewalIntervalMs?: number公开属性;类型、只读和可选状态以签名列为准。
revisions属性revisions: RuntimeActivityRevisionValidator公开属性;类型、只读和可选状态以签名列为准。
runLeases属性runLeases: RunLeaseStore公开属性;类型、只读和可选状态以签名列为准。
wait方法wait?(delayMs: number, signal: AbortSignal): Promise<void>公开方法;参数与返回类型以签名列为准。

RuntimeActivityRevisionValidator

Runtime Activity Revision Validator 接口,共包含 1 个公开字段或方法。

声明

text
export interface RuntimeActivityRevisionValidator {
    validate(input: {
        task: Readonly<RuntimeHumanTask>;
        descriptor: Readonly<RuntimeActivityDescriptor>;
    }): Promise<void>;
}

契约成员

成员种类签名说明
validate方法validate(input: { task: Readonly<RuntimeHumanTask>; descriptor: Readonly<RuntimeActivityDescriptor>; }): Promise<void>公开方法;参数与返回类型以签名列为准。

RuntimeActivityRedispatchReconciliation

Runtime Activity Redispatch Reconciliation 公共类型别名;完整类型表达式见声明。

声明

text
export type RuntimeActivityRedispatchReconciliation = {
    status: 'accepted';
    commandId: string;
} | {
    status: 'safe_to_dispatch';
} | {
    status: 'unknown';
    reason: string;
};