@darlean/fs-persistence-suite
Version:
File System Persistence Suite that uses a physical or shared file system to persist data.
44 lines (43 loc) • 2.33 kB
TypeScript
/// <reference types="node" />
import { IPersistenceLoadOptions, IPersistenceLoadResult, IPersistenceQueryOptions, IPersistenceQueryResult, IPersistenceStoreBatchOptions } from '@darlean/base';
import { IDeSer, IMultiFilter, ITime } from '@darlean/utils';
import { Filterer } from './filtering';
import { SqliteDatabase, StatementPool } from './sqlite-sync';
declare const FIELD_PK = "pk";
declare const FIELD_SK = "sk";
declare const FIELD_VALUE = "value";
export declare class FsPersistenceWorker {
private connection?;
private keyWhere;
private lastSeqNr;
private filterer;
private deser;
constructor(time: ITime, filterer: Filterer, deser: IDeSer);
load(options: IPersistenceLoadOptions): IPersistenceLoadResult<Blob>;
query(options: IPersistenceQueryOptions): IPersistenceQueryResult<Blob>;
storeBatch(options: IPersistenceStoreBatchOptions<Blob>): Promise<void>;
protected project(config: IMultiFilter, data: Buffer | undefined, deserFields: string[]): Buffer | undefined;
protected filter(data: {
[FIELD_PK]?: string;
[FIELD_SK]?: string;
[FIELD_VALUE]?: Buffer;
}, filter: unknown, base: string | undefined, pkOffset: number | undefined, skOffset: number | undefined): boolean;
openDatabase(basePath: string, mode: 'writable' | 'readonly'): void;
protected makeLoadPool(db: SqliteDatabase): StatementPool;
protected makeQueryPoolAsc(db: SqliteDatabase, fields?: string[]): StatementPool;
protected makeQueryPoolDesc(db: SqliteDatabase, fields?: string[]): StatementPool;
protected makeStorePool(db: SqliteDatabase): StatementPool;
protected makeDeletePool(db: SqliteDatabase): StatementPool;
protected makeKeyWhere(): string;
protected makeKeyValues(partitionKey: string[], sortKey: string[] | undefined): string[];
closeDatabase(): Promise<void>;
}
declare const workerdef: {
open: (basePath: string, mode: 'readonly' | 'writable') => void;
close: () => Promise<void>;
load: (options: IPersistenceLoadOptions) => IPersistenceLoadResult<Blob>;
query: (options: IPersistenceQueryOptions) => IPersistenceQueryResult<Blob>;
storeBatch: (options: IPersistenceStoreBatchOptions<Blob>) => Promise<void>;
};
export type WorkerDef = typeof workerdef;
export {};