Skip to content

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

模块用法

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

从包入口导入

ts
import {
  PermanentMemoryMigrationAdapter,
  decidePermanentMemoryFailure,
  isExplicitPermanentMemoryNotFound,
  normalizePermanentMemoryProviderError,
} from '@codesoul-co/hypha-memory';

import type {
  PermanentMemoryFailureDecision,
  PermanentMemoryFailureEvent,
  PermanentMemoryFailureObserver,
  PermanentMemoryMigrationAdapterOptions,
  PermanentMemoryMigrationPort,
  PermanentMemoryMigrationProvider,
  PermanentMemoryMigrationRequest,
  PermanentMemoryFailureDisposition,
} from '@codesoul-co/hypha-memory';

// 完整导出列表见下方。

使用要点

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

公共导出

Symbol种类签名说明
PermanentMemoryMigrationAdapternew PermanentMemoryMigrationAdapter(options: PermanentMemoryMigrationAdapterOptions): PermanentMemoryMigrationAdapterPermanent Memory Migration Adapter 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
decidePermanentMemoryFailure函数decidePermanentMemoryFailure(error: NormalizedMemoryError, request: PermanentMemoryMigrationRequest, operation: PermanentMemoryMigrationOperation): PermanentMemoryFailureDecisionDecide Permanent Memory Failure 函数,提供 1 个公开调用签名;参数与返回类型见下表。
isExplicitPermanentMemoryNotFound函数isExplicitPermanentMemoryNotFound(error: unknown): booleanIs Explicit Permanent Memory Not Found 函数,提供 1 个公开调用签名;参数与返回类型见下表。
normalizePermanentMemoryProviderError函数normalizePermanentMemoryProviderError(providerError: unknown, request: PermanentMemoryMigrationRequest, operation: PermanentMemoryMigrationOperation): NormalizedMemoryErrorNormalize Permanent Memory Provider Error 函数,提供 1 个公开调用签名;参数与返回类型见下表。
PermanentMemoryFailureDecision接口interface PermanentMemoryFailureDecisionPermanent Memory Failure Decision 接口,共包含 6 个公开字段或方法。
PermanentMemoryFailureEvent接口interface PermanentMemoryFailureEventPermanent Memory Failure Event 接口,共包含 10 个公开字段或方法。
PermanentMemoryFailureObserver接口interface PermanentMemoryFailureObserverPermanent Memory Failure Observer 接口,共包含 1 个公开字段或方法。
PermanentMemoryMigrationAdapterOptions接口interface PermanentMemoryMigrationAdapterOptionsPermanent Memory Migration Adapter Options 接口,共包含 2 个公开字段或方法。
PermanentMemoryMigrationPort接口interface PermanentMemoryMigrationPortPermanent Memory Migration Port 接口,共包含 4 个公开字段或方法。
PermanentMemoryMigrationProvider接口interface PermanentMemoryMigrationProviderPermanent Memory Migration Provider 接口,共包含 4 个公开字段或方法。
PermanentMemoryMigrationRequest接口interface PermanentMemoryMigrationRequestPermanent Memory Migration Request 接口,共包含 7 个公开字段或方法。
PermanentMemoryFailureDisposition类型type PermanentMemoryFailureDisposition = 'retry' | 'reconcile' | 'quarantine' | 'dlq'Permanent Memory Failure Disposition 公共类型别名;完整类型表达式见声明。
PermanentMemoryFailureFinalState类型type PermanentMemoryFailureFinalState = 'waiting' | 'reconciling' | 'quarantined' | 'dead_lettered'Permanent Memory Failure Final State 公共类型别名;完整类型表达式见声明。
PermanentMemoryMigrationOperation类型type PermanentMemoryMigrationOperation = 'get' | 'list' | 'delete' | 'write'Permanent Memory Migration Operation 公共类型别名;完整类型表达式见声明。

PermanentMemoryMigrationAdapter

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

声明

text
export declare class PermanentMemoryMigrationAdapter implements PermanentMemoryMigrationPort {
    constructor(options: PermanentMemoryMigrationAdapterOptions);
    get<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue | null>;
    list<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue[]>;
    delete(request: PermanentMemoryMigrationRequest): Promise<boolean>;
    write<TValue = unknown>(request: PermanentMemoryMigrationRequest, value: TValue): Promise<void>;
}

公开成员

成员种类签名说明
constructor构造函数(options: PermanentMemoryMigrationAdapterOptions): PermanentMemoryMigrationAdapter创建该类的实例。
delete方法delete(request: PermanentMemoryMigrationRequest): Promise<boolean>公开方法;参数与返回类型以签名列为准。
get方法get<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue | null>公开方法;参数与返回类型以签名列为准。
list方法list<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue[]>公开方法;参数与返回类型以签名列为准。
write方法write<TValue = unknown>(request: PermanentMemoryMigrationRequest, value: TValue): Promise<void>公开方法;参数与返回类型以签名列为准。

decidePermanentMemoryFailure

Decide Permanent Memory Failure 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function decidePermanentMemoryFailure(error: NormalizedMemoryError, request: PermanentMemoryMigrationRequest, operation: PermanentMemoryMigrationOperation): PermanentMemoryFailureDecision;

调用签名

text
decidePermanentMemoryFailure(error: NormalizedMemoryError, request: PermanentMemoryMigrationRequest, operation: PermanentMemoryMigrationOperation): PermanentMemoryFailureDecision

参数

参数类型必需说明
errorNormalizedMemoryError必需参数;接受的值由类型列定义。
requestPermanentMemoryMigrationRequest必需参数;接受的值由类型列定义。
operationPermanentMemoryMigrationOperation必需参数;接受的值由类型列定义。

返回值

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

isExplicitPermanentMemoryNotFound

Is Explicit Permanent Memory Not Found 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function isExplicitPermanentMemoryNotFound(error: unknown): boolean;

调用签名

text
isExplicitPermanentMemoryNotFound(error: unknown): boolean

参数

参数类型必需说明
errorunknown必需参数;接受的值由类型列定义。

返回值

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

normalizePermanentMemoryProviderError

Normalize Permanent Memory Provider Error 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function normalizePermanentMemoryProviderError(providerError: unknown, request: PermanentMemoryMigrationRequest, operation: PermanentMemoryMigrationOperation): NormalizedMemoryError;

调用签名

text
normalizePermanentMemoryProviderError(providerError: unknown, request: PermanentMemoryMigrationRequest, operation: PermanentMemoryMigrationOperation): NormalizedMemoryError

参数

参数类型必需说明
providerErrorunknown必需参数;接受的值由类型列定义。
requestPermanentMemoryMigrationRequest必需参数;接受的值由类型列定义。
operationPermanentMemoryMigrationOperation必需参数;接受的值由类型列定义。

返回值

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

PermanentMemoryFailureDecision

Permanent Memory Failure Decision 接口,共包含 6 个公开字段或方法。

声明

text
export interface PermanentMemoryFailureDecision {
    disposition: PermanentMemoryFailureDisposition;
    finalState: PermanentMemoryFailureFinalState;
    retryable: boolean;
    attempt: number;
    maxAttempts: number;
    reason: string;
}

契约成员

成员种类签名说明
attempt属性attempt: number公开属性;类型、只读和可选状态以签名列为准。
disposition属性disposition: PermanentMemoryFailureDisposition公开属性;类型、只读和可选状态以签名列为准。
finalState属性finalState: PermanentMemoryFailureFinalState公开属性;类型、只读和可选状态以签名列为准。
maxAttempts属性maxAttempts: number公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: string公开属性;类型、只读和可选状态以签名列为准。
retryable属性retryable: boolean公开属性;类型、只读和可选状态以签名列为准。

PermanentMemoryFailureEvent

Permanent Memory Failure Event 接口,共包含 10 个公开字段或方法。

声明

text
export interface PermanentMemoryFailureEvent {
    type: 'permanent_memory.operation_failed';
    operationId: string;
    operation: PermanentMemoryMigrationOperation;
    providerRef: string;
    profileRef: string;
    scopeHash: string;
    attempt: number;
    error: NormalizedMemoryError;
    disposition: PermanentMemoryFailureDisposition;
    finalState: PermanentMemoryFailureFinalState;
}

契约成员

成员种类签名说明
attempt属性attempt: number公开属性;类型、只读和可选状态以签名列为准。
disposition属性disposition: PermanentMemoryFailureDisposition公开属性;类型、只读和可选状态以签名列为准。
error属性error: NormalizedMemoryError公开属性;类型、只读和可选状态以签名列为准。
finalState属性finalState: PermanentMemoryFailureFinalState公开属性;类型、只读和可选状态以签名列为准。
operation属性operation: PermanentMemoryMigrationOperation公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
profileRef属性profileRef: string公开属性;类型、只读和可选状态以签名列为准。
providerRef属性providerRef: string公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: "permanent_memory.operation_failed"公开属性;类型、只读和可选状态以签名列为准。

PermanentMemoryFailureObserver

Permanent Memory Failure Observer 接口,共包含 1 个公开字段或方法。

声明

text
export interface PermanentMemoryFailureObserver {
    record(event: PermanentMemoryFailureEvent): void | Promise<void>;
}

契约成员

成员种类签名说明
record方法record(event: PermanentMemoryFailureEvent): void | Promise<void>公开方法;参数与返回类型以签名列为准。

PermanentMemoryMigrationAdapterOptions

Permanent Memory Migration Adapter Options 接口,共包含 2 个公开字段或方法。

声明

text
export interface PermanentMemoryMigrationAdapterOptions {
    provider: PermanentMemoryMigrationProvider;
    observer?: PermanentMemoryFailureObserver;
}

契约成员

成员种类签名说明
observer属性observer?: PermanentMemoryFailureObserver公开属性;类型、只读和可选状态以签名列为准。
provider属性provider: PermanentMemoryMigrationProvider公开属性;类型、只读和可选状态以签名列为准。

PermanentMemoryMigrationPort

Permanent Memory Migration Port 接口,共包含 4 个公开字段或方法。

声明

text
export interface PermanentMemoryMigrationPort {
    get<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue | null>;
    list<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue[]>;
    delete(request: PermanentMemoryMigrationRequest): Promise<boolean>;
    write<TValue = unknown>(request: PermanentMemoryMigrationRequest, value: TValue): Promise<void>;
}

契约成员

成员种类签名说明
delete方法delete(request: PermanentMemoryMigrationRequest): Promise<boolean>公开方法;参数与返回类型以签名列为准。
get方法get<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue | null>公开方法;参数与返回类型以签名列为准。
list方法list<TValue = unknown>(request: PermanentMemoryMigrationRequest): Promise<TValue[]>公开方法;参数与返回类型以签名列为准。
write方法write<TValue = unknown>(request: PermanentMemoryMigrationRequest, value: TValue): Promise<void>公开方法;参数与返回类型以签名列为准。

PermanentMemoryMigrationProvider

Permanent Memory Migration Provider 接口,共包含 4 个公开字段或方法。

声明

text
export interface PermanentMemoryMigrationProvider {
    get<TValue = unknown>(scope: ManagedMemoryScope, recordId: string): Promise<TValue | null>;
    list<TValue = unknown>(scope: ManagedMemoryScope): Promise<TValue[]>;
    delete(scope: ManagedMemoryScope, recordId: string): Promise<boolean>;
    write<TValue = unknown>(scope: ManagedMemoryScope, recordId: string, value: TValue): Promise<void>;
}

契约成员

成员种类签名说明
delete方法delete(scope: ManagedMemoryScope, recordId: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
get方法get<TValue = unknown>(scope: ManagedMemoryScope, recordId: string): Promise<TValue | null>公开方法;参数与返回类型以签名列为准。
list方法list<TValue = unknown>(scope: ManagedMemoryScope): Promise<TValue[]>公开方法;参数与返回类型以签名列为准。
write方法write<TValue = unknown>(scope: ManagedMemoryScope, recordId: string, value: TValue): Promise<void>公开方法;参数与返回类型以签名列为准。

PermanentMemoryMigrationRequest

Permanent Memory Migration Request 接口,共包含 7 个公开字段或方法。

声明

text
export interface PermanentMemoryMigrationRequest {
    operationId: string;
    scope: ManagedMemoryScope;
    providerRef: string;
    profileRef: string;
    recordId?: string;
    attempt?: number;
    maxAttempts?: number;
}

契约成员

成员种类签名说明
attempt属性attempt?: number公开属性;类型、只读和可选状态以签名列为准。
maxAttempts属性maxAttempts?: number公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
profileRef属性profileRef: string公开属性;类型、只读和可选状态以签名列为准。
providerRef属性providerRef: string公开属性;类型、只读和可选状态以签名列为准。
recordId属性recordId?: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: ManagedMemoryScope公开属性;类型、只读和可选状态以签名列为准。

PermanentMemoryFailureDisposition

Permanent Memory Failure Disposition 公共类型别名;完整类型表达式见声明。

声明

text
export type PermanentMemoryFailureDisposition = 'retry' | 'reconcile' | 'quarantine' | 'dlq';

PermanentMemoryFailureFinalState

Permanent Memory Failure Final State 公共类型别名;完整类型表达式见声明。

声明

text
export type PermanentMemoryFailureFinalState = 'waiting' | 'reconciling' | 'quarantined' | 'dead_lettered';

PermanentMemoryMigrationOperation

Permanent Memory Migration Operation 公共类型别名;完整类型表达式见声明。

声明

text
export type PermanentMemoryMigrationOperation = 'get' | 'list' | 'delete' | 'write';