Skip to content

@codesoul-co/hypha-memory / memory-server-migration-rehearsal

模块用法

用于使用该功能边界的公共契约与操作。Memory server migration rehearsal 模块公开 1 类、1 函数、7 接口。

从包入口导入

ts
import {
  MemoryServerMigrationRehearsal,
  planMemoryServerMigrationInventories,
} from '@codesoul-co/hypha-memory';

import type {
  MemoryServerMigrationFinishInput,
  MemoryServerMigrationInventoryPlan,
  MemoryServerMigrationInventoryRecord,
  MemoryServerMigrationPrepareInput,
  MemoryServerMigrationRehearsalCheckpoint,
  MemoryServerMigrationRehearsalCheckpointStore,
  MemoryServerMigrationRehearsalDataPort,
} from '@codesoul-co/hypha-memory';

使用要点

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

公共导出

Symbol种类签名说明
MemoryServerMigrationRehearsalnew MemoryServerMigrationRehearsal(data: MemoryServerMigrationRehearsalDataPort, store: MemoryServerMigrationRehearsalCheckpointStore): MemoryServerMigrationRehearsalMemory Server Migration Rehearsal 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
planMemoryServerMigrationInventories函数planMemoryServerMigrationInventories(legacyInput: readonly MemoryServerMigrationInventoryRecord[], canonicalInput: readonly MemoryServerMigrationInventoryRecord[]): MemoryServerMigrationInventoryPlanPlan Memory Server Migration Inventories 函数,提供 1 个公开调用签名;参数与返回类型见下表。
MemoryServerMigrationFinishInput接口interface MemoryServerMigrationFinishInputMemory Server Migration Finish Input 接口,共包含 3 个公开字段或方法。
MemoryServerMigrationInventoryPlan接口interface MemoryServerMigrationInventoryPlanMemory Server Migration Inventory Plan 接口,共包含 7 个公开字段或方法。
MemoryServerMigrationInventoryRecord接口interface MemoryServerMigrationInventoryRecordMemory Server Migration Inventory Record 接口,共包含 2 个公开字段或方法。
MemoryServerMigrationPrepareInput接口interface MemoryServerMigrationPrepareInputMemory Server Migration Prepare Input 接口,共包含 5 个公开字段或方法。
MemoryServerMigrationRehearsalCheckpoint接口interface MemoryServerMigrationRehearsalCheckpointMemory Server Migration Rehearsal Checkpoint 接口,共包含 4 个公开字段或方法。
MemoryServerMigrationRehearsalCheckpointStore接口interface MemoryServerMigrationRehearsalCheckpointStoreMemory Server Migration Rehearsal Checkpoint Store 接口,共包含 2 个公开字段或方法。
MemoryServerMigrationRehearsalDataPort接口interface MemoryServerMigrationRehearsalDataPortMemory Server Migration Rehearsal Data Port 接口,共包含 6 个公开字段或方法。

MemoryServerMigrationRehearsal

Memory Server Migration Rehearsal 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。

声明

text
export declare class MemoryServerMigrationRehearsal {
    constructor(data: MemoryServerMigrationRehearsalDataPort, store: MemoryServerMigrationRehearsalCheckpointStore);
    plan(): Promise<MemoryServerMigrationInventoryPlan>;
    prepare(input: MemoryServerMigrationPrepareInput): Promise<MemoryServerMigrationRehearsalCheckpoint>;
    rollback(input: MemoryServerMigrationFinishInput): Promise<MemoryServerMigrationRehearsalCheckpoint>;
    retire(input: MemoryServerMigrationFinishInput & {
            rollbackWindowEndsAt: string;
        }): Promise<MemoryServerMigrationRehearsalCheckpoint>;
}

公开成员

成员种类签名说明
constructor构造函数(data: MemoryServerMigrationRehearsalDataPort, store: MemoryServerMigrationRehearsalCheckpointStore): MemoryServerMigrationRehearsal创建该类的实例。
plan方法plan(): Promise<MemoryServerMigrationInventoryPlan>公开方法;参数与返回类型以签名列为准。
prepare方法prepare(input: MemoryServerMigrationPrepareInput): Promise<MemoryServerMigrationRehearsalCheckpoint>公开方法;参数与返回类型以签名列为准。
retire方法retire(input: MemoryServerMigrationFinishInput & { rollbackWindowEndsAt: string; }): Promise<MemoryServerMigrationRehearsalCheckpoint>公开方法;参数与返回类型以签名列为准。
rollback方法rollback(input: MemoryServerMigrationFinishInput): Promise<MemoryServerMigrationRehearsalCheckpoint>公开方法;参数与返回类型以签名列为准。

planMemoryServerMigrationInventories

Plan Memory Server Migration Inventories 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function planMemoryServerMigrationInventories(legacyInput: readonly MemoryServerMigrationInventoryRecord[], canonicalInput: readonly MemoryServerMigrationInventoryRecord[]): MemoryServerMigrationInventoryPlan;

调用签名

text
planMemoryServerMigrationInventories(legacyInput: readonly MemoryServerMigrationInventoryRecord[], canonicalInput: readonly MemoryServerMigrationInventoryRecord[]): MemoryServerMigrationInventoryPlan

参数

参数类型必需说明
legacyInputreadonly MemoryServerMigrationInventoryRecord[]必需参数;接受的值由类型列定义。
canonicalInputreadonly MemoryServerMigrationInventoryRecord[]必需参数;接受的值由类型列定义。

返回值

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

MemoryServerMigrationFinishInput

Memory Server Migration Finish Input 接口,共包含 3 个公开字段或方法。

声明

text
export interface MemoryServerMigrationFinishInput {
    migrationId: string;
    expectedRevision: string;
    occurredAt: string;
}

契约成员

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

MemoryServerMigrationInventoryPlan

Memory Server Migration Inventory Plan 接口,共包含 7 个公开字段或方法。

声明

text
export interface MemoryServerMigrationInventoryPlan {
    legacyRecords: number;
    canonicalRecords: number;
    matchingRecords: number;
    missingCanonicalKeys: string[];
    unexpectedCanonicalKeys: string[];
    digestMismatchKeys: string[];
    reconciliation: MemoryServerMigrationReconciliation;
}

契约成员

成员种类签名说明
canonicalRecords属性canonicalRecords: number公开属性;类型、只读和可选状态以签名列为准。
digestMismatchKeys属性digestMismatchKeys: string[]公开属性;类型、只读和可选状态以签名列为准。
legacyRecords属性legacyRecords: number公开属性;类型、只读和可选状态以签名列为准。
matchingRecords属性matchingRecords: number公开属性;类型、只读和可选状态以签名列为准。
missingCanonicalKeys属性missingCanonicalKeys: string[]公开属性;类型、只读和可选状态以签名列为准。
reconciliation属性reconciliation: MemoryServerMigrationReconciliation公开属性;类型、只读和可选状态以签名列为准。
unexpectedCanonicalKeys属性unexpectedCanonicalKeys: string[]公开属性;类型、只读和可选状态以签名列为准。

MemoryServerMigrationInventoryRecord

Memory Server Migration Inventory Record 接口,共包含 2 个公开字段或方法。

声明

text
export interface MemoryServerMigrationInventoryRecord {
    key: string;
    digest: string;
}

契约成员

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

MemoryServerMigrationPrepareInput

Memory Server Migration Prepare Input 接口,共包含 5 个公开字段或方法。

声明

text
export interface MemoryServerMigrationPrepareInput {
    migrationId: string;
    revision: string;
    occurredAt: string;
    dualWriteDeadlineAt: string;
    checkpointRef: string;
}

契约成员

成员种类签名说明
checkpointRef属性checkpointRef: string公开属性;类型、只读和可选状态以签名列为准。
dualWriteDeadlineAt属性dualWriteDeadlineAt: string公开属性;类型、只读和可选状态以签名列为准。
migrationId属性migrationId: string公开属性;类型、只读和可选状态以签名列为准。
occurredAt属性occurredAt: string公开属性;类型、只读和可选状态以签名列为准。
revision属性revision: string公开属性;类型、只读和可选状态以签名列为准。

MemoryServerMigrationRehearsalCheckpoint

Memory Server Migration Rehearsal Checkpoint 接口,共包含 4 个公开字段或方法。

声明

text
export interface MemoryServerMigrationRehearsalCheckpoint {
    state: MemoryServerCanonicalMigrationState;
    events: readonly MemoryServerMigrationTransitionEvent[];
    importedCanonicalIds: readonly string[];
    reconciliation: MemoryServerMigrationReconciliation;
}

契约成员

成员种类签名说明
events属性events: readonly MemoryServerMigrationTransitionEvent[]公开属性;类型、只读和可选状态以签名列为准。
importedCanonicalIds属性importedCanonicalIds: readonly string[]公开属性;类型、只读和可选状态以签名列为准。
reconciliation属性reconciliation: MemoryServerMigrationReconciliation公开属性;类型、只读和可选状态以签名列为准。
state属性state: MemoryServerCanonicalMigrationState公开属性;类型、只读和可选状态以签名列为准。

MemoryServerMigrationRehearsalCheckpointStore

Memory Server Migration Rehearsal Checkpoint Store 接口,共包含 2 个公开字段或方法。

声明

text
export interface MemoryServerMigrationRehearsalCheckpointStore {
    load(migrationId: string): Promise<MemoryServerMigrationRehearsalCheckpoint | null>;
    save(migrationId: string, checkpoint: MemoryServerMigrationRehearsalCheckpoint): Promise<void>;
}

契约成员

成员种类签名说明
load方法load(migrationId: string): Promise<MemoryServerMigrationRehearsalCheckpoint | null>公开方法;参数与返回类型以签名列为准。
save方法save(migrationId: string, checkpoint: MemoryServerMigrationRehearsalCheckpoint): Promise<void>公开方法;参数与返回类型以签名列为准。

MemoryServerMigrationRehearsalDataPort

Memory Server Migration Rehearsal Data Port 接口,共包含 6 个公开字段或方法。

声明

text
export interface MemoryServerMigrationRehearsalDataPort {
    listLegacy(): Promise<readonly MemoryServerMigrationInventoryRecord[]>;
    listCanonical(): Promise<readonly MemoryServerMigrationInventoryRecord[]>;
    importCanonical(record: MemoryServerMigrationInventoryRecord, idempotencyKey: string): Promise<{
        canonicalId: string;
    }>;
    writeDualProbe(idempotencyKey: string): Promise<{
        record: MemoryServerMigrationInventoryRecord;
        canonicalId: string;
    }>;
    removeCanonical(canonicalIds: readonly string[]): Promise<void>;
    observeRetirement(): Promise<Omit<MemoryServerMigrationRetirementEvidence, 'rollbackWindowEndsAt'>>;
}

契约成员

成员种类签名说明
importCanonical方法importCanonical(record: MemoryServerMigrationInventoryRecord, idempotencyKey: string): Promise<{ canonicalId: string; }>公开方法;参数与返回类型以签名列为准。
listCanonical方法listCanonical(): Promise<readonly MemoryServerMigrationInventoryRecord[]>公开方法;参数与返回类型以签名列为准。
listLegacy方法listLegacy(): Promise<readonly MemoryServerMigrationInventoryRecord[]>公开方法;参数与返回类型以签名列为准。
observeRetirement方法observeRetirement(): Promise<Omit<MemoryServerMigrationRetirementEvidence, "rollbackWindowEndsAt">>公开方法;参数与返回类型以签名列为准。
removeCanonical方法removeCanonical(canonicalIds: readonly string[]): Promise<void>公开方法;参数与返回类型以签名列为准。
writeDualProbe方法writeDualProbe(idempotencyKey: string): Promise<{ record: MemoryServerMigrationInventoryRecord; canonicalId: string; }>公开方法;参数与返回类型以签名列为准。