Skip to content

@codesoul-co/hypha-adapters-local / runtime-event-store

模块用法

用于创建、记录或读取 Event 契约。Runtime event store 模块公开 1 类、2 接口。

从包入口导入

ts
import {
  SQLiteDurableEventStore,
} from '@codesoul-co/hypha-adapters-local';

import type {
  SQLiteDurableEventStoreOptions,
  SQLiteImportedEventResetResult,
} from '@codesoul-co/hypha-adapters-local';

使用要点

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

公共导出

Symbol种类签名说明
SQLiteDurableEventStorenew SQLiteDurableEventStore(options: SQLiteDurableEventStoreOptions): SQLiteDurableEventStoreSQLite Durable Event Store 类,共公开 10 个构造函数或成员;精确签名见本条目的声明与成员表。
SQLiteDurableEventStoreOptions接口interface SQLiteDurableEventStoreOptionsSQLite Durable Event Store Options 接口,共包含 3 个公开字段或方法。
SQLiteImportedEventResetResult接口interface SQLiteImportedEventResetResultSQLite Imported Event Reset Result 接口,共包含 3 个公开字段或方法。

SQLiteDurableEventStore

SQLite Durable Event Store 类,共公开 10 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { SQLiteDurableEventStore } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: runtime-event-store

声明

text
export declare class SQLiteDurableEventStore implements DurableEventStore, CanonicalEventScanPort {
    constructor(options: SQLiteDurableEventStoreOptions);
    append(request: EventAppendRequest): Promise<EventAppendResult>;
    readStream(scope: EventStreamScope, fromSequence?: number): Promise<PersistedFrameworkEvent[]>;
    readById(scope: EventStreamScope, eventId: string): Promise<PersistedFrameworkEvent | null>;
    getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>;
    listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>;
    health(): Promise<ProviderHealth>;
    resetUnauditedImportedEvents(): Promise<SQLiteImportedEventResetResult>;
    scanCanonicalEvents(request: ScanCanonicalEventsRequest): Promise<ScanCanonicalEventsResult>;
    close(): void;
}

公开成员

成员种类签名说明
append方法append(request: EventAppendRequest): Promise<EventAppendResult>公开方法;参数与返回类型以签名列为准。
close方法close(): void公开方法;参数与返回类型以签名列为准。
constructor构造函数(options: SQLiteDurableEventStoreOptions): SQLiteDurableEventStore创建该类的实例。
getStreamHead方法getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
listStreamHeads方法listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>公开方法;参数与返回类型以签名列为准。
readById方法readById(scope: EventStreamScope, eventId: string): Promise<PersistedFrameworkEvent | null>公开方法;参数与返回类型以签名列为准。
readStream方法readStream(scope: EventStreamScope, fromSequence?: number): Promise<PersistedFrameworkEvent[]>公开方法;参数与返回类型以签名列为准。
resetUnauditedImportedEvents方法resetUnauditedImportedEvents(): Promise<SQLiteImportedEventResetResult>Clears only an incomplete compatibility import. A successful integrity watermark or any live/non-imported Event makes the operation fail closed.
scanCanonicalEvents方法scanCanonicalEvents(request: ScanCanonicalEventsRequest): Promise<ScanCanonicalEventsResult>公开方法;参数与返回类型以签名列为准。

SQLiteDurableEventStoreOptions

SQLite Durable Event Store Options 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { SQLiteDurableEventStoreOptions } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: runtime-event-store

声明

text
export interface SQLiteDurableEventStoreOptions {
    filename: string;
    schemaRegistry: EventSchemaRegistry;
    now?: () => string;
}

契约成员

成员种类签名说明
filename属性filename: string公开属性;类型、只读和可选状态以签名列为准。
now方法now?(): string公开方法;参数与返回类型以签名列为准。
schemaRegistry属性schemaRegistry: EventSchemaRegistry公开属性;类型、只读和可选状态以签名列为准。

SQLiteImportedEventResetResult

SQLite Imported Event Reset Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { SQLiteImportedEventResetResult } from '@codesoul-co/hypha-adapters-local';
  • 源码模块: runtime-event-store

声明

text
export interface SQLiteImportedEventResetResult {
    reset: boolean;
    deletedEvents: number;
    reason: 'empty' | 'reset' | 'audited_history' | 'non_imported_events';
}

契约成员

成员种类签名说明
deletedEvents属性deletedEvents: number公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: "empty" | "reset" | "audited_history" | "non_imported_events"公开属性;类型、只读和可选状态以签名列为准。
reset属性reset: boolean公开属性;类型、只读和可选状态以签名列为准。