Skip to content

@codesoul-co/hypha-memory / structured-memory-persistence

模块用法

用于持久化并读取该边界的数据。Structured memory persistence 模块公开 2 类、2 接口。

从包入口导入

ts
import {
  StructuredMemoryIndexOutboxStore,
  StructuredMemoryPersistenceUnitOfWork,
} from '@codesoul-co/hypha-memory';

import type {
  StructuredMemoryIndexOutboxStoreOptions,
  StructuredMemoryPersistenceUnitOfWorkOptions,
} from '@codesoul-co/hypha-memory';

使用要点

  • 2 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 2 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。

公共导出

Symbol种类签名说明
StructuredMemoryIndexOutboxStorenew StructuredMemoryIndexOutboxStore(options: StructuredMemoryIndexOutboxStoreOptions): StructuredMemoryIndexOutboxStoreStructured Memory Index Outbox Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。
StructuredMemoryPersistenceUnitOfWorknew StructuredMemoryPersistenceUnitOfWork(options: StructuredMemoryPersistenceUnitOfWorkOptions): StructuredMemoryPersistenceUnitOfWorkStructured Memory Persistence Unit Of Work 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
StructuredMemoryIndexOutboxStoreOptions接口interface StructuredMemoryIndexOutboxStoreOptionsStructured Memory Index Outbox Store Options 接口,共包含 3 个公开字段或方法。
StructuredMemoryPersistenceUnitOfWorkOptions接口interface StructuredMemoryPersistenceUnitOfWorkOptionsStructured Memory Persistence Unit Of Work Options 接口,共包含 4 个公开字段或方法。

StructuredMemoryIndexOutboxStore

Structured Memory Index Outbox Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。

声明

text
export declare class StructuredMemoryIndexOutboxStore implements MemoryIndexOutboxStore {
    constructor(options: StructuredMemoryIndexOutboxStoreOptions);
    enqueue(record: MemoryIndexOutboxRecord): Promise<void>;
    lease(owner: string, now: string, leaseUntil: string, limit: number): Promise<MemoryIndexOutboxRecord[]>;
    renew(id: string, owner: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>;
    complete(id: string, owner: string, leaseToken: string, now: string): Promise<boolean>;
    fail(id: string, owner: string, leaseToken: string, now: string, error: NormalizedMemoryError, retryAt: string, deadLetter?: boolean): Promise<boolean>;
    list(): Promise<MemoryIndexOutboxRecord[]>;
    transaction<T>(fn: (store: MemoryIndexOutboxStore) => Promise<T>): Promise<T>;
}

公开成员

成员种类签名说明
complete方法complete(id: string, owner: string, leaseToken: string, now: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
constructor构造函数(options: StructuredMemoryIndexOutboxStoreOptions): StructuredMemoryIndexOutboxStore创建该类的实例。
enqueue方法enqueue(record: MemoryIndexOutboxRecord): Promise<void>公开方法;参数与返回类型以签名列为准。
fail方法fail(id: string, owner: string, leaseToken: string, now: string, error: NormalizedMemoryError, retryAt: string, deadLetter?: boolean): Promise<boolean>公开方法;参数与返回类型以签名列为准。
lease方法lease(owner: string, now: string, leaseUntil: string, limit: number): Promise<MemoryIndexOutboxRecord[]>公开方法;参数与返回类型以签名列为准。
list方法list(): Promise<MemoryIndexOutboxRecord[]>公开方法;参数与返回类型以签名列为准。
renew方法renew(id: string, owner: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
transaction方法transaction<T>(fn: (store: MemoryIndexOutboxStore) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。

StructuredMemoryPersistenceUnitOfWork

Structured Memory Persistence Unit Of Work 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。

声明

text
export declare class StructuredMemoryPersistenceUnitOfWork implements MemoryPersistenceUnitOfWork {
    readonly capabilities: MemoryPersistenceCapabilities;
    readonly recordStore: StructuredManagedMemoryRecordStore;
    readonly outboxStore: StructuredMemoryIndexOutboxStore;
    constructor(options: StructuredMemoryPersistenceUnitOfWorkOptions);
    transaction<T>(fn: (stores: MemoryPersistenceTransaction) => Promise<T>): Promise<T>;
}

公开成员

成员种类签名说明
capabilities属性readonly capabilities: MemoryPersistenceCapabilities公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(options: StructuredMemoryPersistenceUnitOfWorkOptions): StructuredMemoryPersistenceUnitOfWork创建该类的实例。
outboxStore属性readonly outboxStore: StructuredMemoryIndexOutboxStore公开属性;类型、只读和可选状态以签名列为准。
recordStore属性readonly recordStore: StructuredManagedMemoryRecordStore公开属性;类型、只读和可选状态以签名列为准。
transaction方法transaction<T>(fn: (stores: MemoryPersistenceTransaction) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。

StructuredMemoryIndexOutboxStoreOptions

Structured Memory Index Outbox Store Options 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { StructuredMemoryIndexOutboxStoreOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: structured-memory-persistence

声明

text
export interface StructuredMemoryIndexOutboxStoreOptions {
    provider: StructuredStoreProvider;
    table?: string;
    inTransaction?: boolean;
}

契约成员

成员种类签名说明
inTransaction属性inTransaction?: boolean公开属性;类型、只读和可选状态以签名列为准。
provider属性provider: StructuredStoreProvider公开属性;类型、只读和可选状态以签名列为准。
table属性table?: string公开属性;类型、只读和可选状态以签名列为准。

StructuredMemoryPersistenceUnitOfWorkOptions

Structured Memory Persistence Unit Of Work Options 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { StructuredMemoryPersistenceUnitOfWorkOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: structured-memory-persistence

声明

text
export interface StructuredMemoryPersistenceUnitOfWorkOptions {
    provider: StructuredStoreProvider;
    currentTable?: string;
    versionsTable?: string;
    outboxTable?: string;
}

契约成员

成员种类签名说明
currentTable属性currentTable?: string公开属性;类型、只读和可选状态以签名列为准。
outboxTable属性outboxTable?: string公开属性;类型、只读和可选状态以签名列为准。
provider属性provider: StructuredStoreProvider公开属性;类型、只读和可选状态以签名列为准。
versionsTable属性versionsTable?: string公开属性;类型、只读和可选状态以签名列为准。