UNPKG

@aurios/jason

Version:

A simple, lightweight, and embeddable JSON document database built on Bun.

21 lines (19 loc) 680 B
import { Path } from "@effect/platform"; import { Effect } from "effect"; import { makeWal } from "../make/wal.js"; import { ConfigManager } from "./config.js"; import { Json } from "./json.js"; export class WriteAheadLog extends Effect.Service<WriteAheadLog>()( "WriteAheadLog", { dependencies: [Json.Default], scoped: Effect.gen(function* () { const path = yield* Path.Path; const config = yield* ConfigManager; const db_path = yield* config.getBasePath; const wal_path = path.join(db_path, "_wal"); // database root const MAX_SEGMENT_SIZE = 1024 * 1024; // 1MB return yield* makeWal(wal_path, MAX_SEGMENT_SIZE); }) } ) {}