@jsonjoy.com/reactive-rpc
Version:
Reactive-RPC is a library for building reactive APIs over WebSocket, HTTP, and other RPCs.
46 lines (45 loc) • 1.9 kB
TypeScript
import type { StoreSnapshot, StoreIncomingBatch, StoreBatch, Store } from './store/types';
import type { Services } from '../Services';
import type { Observable } from 'rxjs';
import type { TBlockEvent } from '../../routes/block/schema';
export interface BlocksServicesOpts {
historyPerBlock: number;
historyCompactionDecision: (seq: number, pushSize: number) => boolean;
spaceReclaimDecision?: () => Promise<number>;
}
export declare class BlocksServices {
protected readonly services: Services;
protected readonly store: Store;
protected readonly opts: BlocksServicesOpts;
protected readonly spaceReclaimDecision: Required<BlocksServicesOpts>['spaceReclaimDecision'];
constructor(services: Services, store?: Store, opts?: BlocksServicesOpts);
create(id: string, batch?: StoreIncomingBatch): Promise<import("./store/types").StoreCreateResult>;
private __emitNew;
private __emitUpd;
get(id: string): Promise<import("./store/types").StoreGetResult>;
view(id: string): Promise<Readonly<unknown>>;
remove(id: string): Promise<boolean>;
scan(id: string, includeStartSnapshot: boolean, offset: number | undefined, limit?: number | undefined): Promise<{
snapshot: StoreSnapshot;
batches: StoreBatch[];
} | {
batches: StoreBatch[];
snapshot?: undefined;
}>;
pull(id: string, lastKnownSeq: number, create?: boolean): Promise<{
batches: StoreBatch[];
snapshot?: StoreSnapshot;
}>;
edit(id: string, batch: StoreIncomingBatch, createIfNotExists: boolean): Promise<{
snapshot: StoreSnapshot;
batch: StoreBatch;
}>;
protected compact(id: string, to: number): Promise<void>;
listen(id: string): Observable<TBlockEvent>;
stats(): {
blocks: number;
batches: number;
};
protected gc(): Promise<void>;
stop(): Promise<void>;
}