@smthrs/journal 0.0.0-stage → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +149 -0
- package/LICENSE +21 -0
- package/README.md +206 -2
- package/dist/cjs/CallFact.d.ts +129 -0
- package/dist/cjs/CallFact.d.ts.map +1 -0
- package/dist/cjs/CallFact.js +106 -0
- package/dist/cjs/CallFact.js.map +7 -0
- package/dist/cjs/Consensus.d.ts +440 -0
- package/dist/cjs/Consensus.d.ts.map +1 -0
- package/dist/cjs/Consensus.js +251 -0
- package/dist/cjs/Consensus.js.map +7 -0
- package/dist/cjs/EngineEvent.d.ts +890 -0
- package/dist/cjs/EngineEvent.d.ts.map +1 -0
- package/dist/cjs/EngineEvent.js +383 -0
- package/dist/cjs/EngineEvent.js.map +7 -0
- package/dist/cjs/ExecutionFact.d.ts +216 -0
- package/dist/cjs/ExecutionFact.d.ts.map +1 -0
- package/dist/cjs/ExecutionFact.js +303 -0
- package/dist/cjs/ExecutionFact.js.map +7 -0
- package/dist/cjs/Journal.d.ts +617 -0
- package/dist/cjs/Journal.d.ts.map +1 -0
- package/dist/cjs/Journal.js +190 -0
- package/dist/cjs/Journal.js.map +7 -0
- package/dist/cjs/JournalEvent.d.ts +421 -0
- package/dist/cjs/JournalEvent.d.ts.map +1 -0
- package/dist/cjs/JournalEvent.js +281 -0
- package/dist/cjs/JournalEvent.js.map +7 -0
- package/dist/cjs/JournalGeneration.d.ts +34 -0
- package/dist/cjs/JournalGeneration.d.ts.map +1 -0
- package/dist/cjs/JournalGeneration.js +72 -0
- package/dist/cjs/JournalGeneration.js.map +7 -0
- package/dist/cjs/JournalMetrics.d.ts +72 -0
- package/dist/cjs/JournalMetrics.d.ts.map +1 -0
- package/dist/cjs/JournalMetrics.js +55 -0
- package/dist/cjs/JournalMetrics.js.map +7 -0
- package/dist/cjs/Migrations.d.ts +42 -0
- package/dist/cjs/Migrations.d.ts.map +1 -0
- package/dist/cjs/Migrations.js +58 -0
- package/dist/cjs/Migrations.js.map +7 -0
- package/dist/cjs/OwnerId.d.ts +40 -0
- package/dist/cjs/OwnerId.d.ts.map +1 -0
- package/dist/cjs/OwnerId.js +40 -0
- package/dist/cjs/OwnerId.js.map +7 -0
- package/dist/cjs/Projection.d.ts +29 -0
- package/dist/cjs/Projection.d.ts.map +1 -0
- package/dist/cjs/Projection.js +25 -0
- package/dist/cjs/Projection.js.map +7 -0
- package/dist/cjs/RedactedLogger.d.ts +121 -0
- package/dist/cjs/RedactedLogger.d.ts.map +1 -0
- package/dist/cjs/RedactedLogger.js +235 -0
- package/dist/cjs/RedactedLogger.js.map +7 -0
- package/dist/cjs/Redaction.d.ts +350 -0
- package/dist/cjs/Redaction.d.ts.map +1 -0
- package/dist/cjs/Redaction.js +928 -0
- package/dist/cjs/Redaction.js.map +7 -0
- package/dist/cjs/SqlConsensus.d.ts +44 -0
- package/dist/cjs/SqlConsensus.d.ts.map +1 -0
- package/dist/cjs/SqlConsensus.js +243 -0
- package/dist/cjs/SqlConsensus.js.map +7 -0
- package/dist/cjs/SqlJournal.d.ts +173 -0
- package/dist/cjs/SqlJournal.d.ts.map +1 -0
- package/dist/cjs/SqlJournal.js +1568 -0
- package/dist/cjs/SqlJournal.js.map +7 -0
- package/dist/cjs/StepFact.d.ts +66 -0
- package/dist/cjs/StepFact.d.ts.map +1 -0
- package/dist/cjs/StepFact.js +68 -0
- package/dist/cjs/StepFact.js.map +7 -0
- package/dist/cjs/index.d.ts +95 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/JournalInternalFault.d.ts +37 -0
- package/dist/cjs/internal/JournalInternalFault.d.ts.map +1 -0
- package/dist/cjs/internal/JournalInternalFault.js +43 -0
- package/dist/cjs/internal/JournalInternalFault.js.map +7 -0
- package/dist/cjs/migrations/0001_initial.d.ts +15 -0
- package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
- package/dist/cjs/migrations/0001_initial.js +54 -0
- package/dist/cjs/migrations/0001_initial.js.map +7 -0
- package/dist/cjs/migrations/0002_checkpoints.d.ts +27 -0
- package/dist/cjs/migrations/0002_checkpoints.d.ts.map +1 -0
- package/dist/cjs/migrations/0002_checkpoints.js +48 -0
- package/dist/cjs/migrations/0002_checkpoints.js.map +7 -0
- package/dist/cjs/migrations/0003_startup_index.d.ts +15 -0
- package/dist/cjs/migrations/0003_startup_index.d.ts.map +1 -0
- package/dist/cjs/migrations/0003_startup_index.js +40 -0
- package/dist/cjs/migrations/0003_startup_index.js.map +7 -0
- package/dist/cjs/migrations/0004_dedup.d.ts +15 -0
- package/dist/cjs/migrations/0004_dedup.d.ts.map +1 -0
- package/dist/cjs/migrations/0004_dedup.js +57 -0
- package/dist/cjs/migrations/0004_dedup.js.map +7 -0
- package/dist/cjs/migrations/0005_run_event_type.d.ts +15 -0
- package/dist/cjs/migrations/0005_run_event_type.d.ts.map +1 -0
- package/dist/cjs/migrations/0005_run_event_type.js +40 -0
- package/dist/cjs/migrations/0005_run_event_type.js.map +7 -0
- package/dist/cjs/migrations/0006_consensus.d.ts +22 -0
- package/dist/cjs/migrations/0006_consensus.d.ts.map +1 -0
- package/dist/cjs/migrations/0006_consensus.js +84 -0
- package/dist/cjs/migrations/0006_consensus.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/Notifying.d.ts +65 -0
- package/dist/cjs/test/Notifying.d.ts.map +1 -0
- package/dist/cjs/test/Notifying.js +62 -0
- package/dist/cjs/test/Notifying.js.map +7 -0
- package/dist/cjs/test/TestJournal.d.ts +43 -0
- package/dist/cjs/test/TestJournal.d.ts.map +1 -0
- package/dist/cjs/test/TestJournal.js +43 -0
- package/dist/cjs/test/TestJournal.js.map +7 -0
- package/dist/esm/CallFact.d.ts +129 -0
- package/dist/esm/CallFact.d.ts.map +1 -0
- package/dist/esm/CallFact.js +96 -0
- package/dist/esm/CallFact.js.map +1 -0
- package/dist/esm/Consensus.d.ts +440 -0
- package/dist/esm/Consensus.d.ts.map +1 -0
- package/dist/esm/Consensus.js +454 -0
- package/dist/esm/Consensus.js.map +1 -0
- package/dist/esm/EngineEvent.d.ts +890 -0
- package/dist/esm/EngineEvent.d.ts.map +1 -0
- package/dist/esm/EngineEvent.js +614 -0
- package/dist/esm/EngineEvent.js.map +1 -0
- package/dist/esm/ExecutionFact.d.ts +216 -0
- package/dist/esm/ExecutionFact.d.ts.map +1 -0
- package/dist/esm/ExecutionFact.js +374 -0
- package/dist/esm/ExecutionFact.js.map +1 -0
- package/dist/esm/Journal.d.ts +617 -0
- package/dist/esm/Journal.d.ts.map +1 -0
- package/dist/esm/Journal.js +323 -0
- package/dist/esm/Journal.js.map +1 -0
- package/dist/esm/JournalEvent.d.ts +421 -0
- package/dist/esm/JournalEvent.d.ts.map +1 -0
- package/dist/esm/JournalEvent.js +517 -0
- package/dist/esm/JournalEvent.js.map +1 -0
- package/dist/esm/JournalGeneration.d.ts +34 -0
- package/dist/esm/JournalGeneration.d.ts.map +1 -0
- package/dist/esm/JournalGeneration.js +65 -0
- package/dist/esm/JournalGeneration.js.map +1 -0
- package/dist/esm/JournalMetrics.d.ts +72 -0
- package/dist/esm/JournalMetrics.d.ts.map +1 -0
- package/dist/esm/JournalMetrics.js +79 -0
- package/dist/esm/JournalMetrics.js.map +1 -0
- package/dist/esm/Migrations.d.ts +42 -0
- package/dist/esm/Migrations.d.ts.map +1 -0
- package/dist/esm/Migrations.js +59 -0
- package/dist/esm/Migrations.js.map +1 -0
- package/dist/esm/OwnerId.d.ts +40 -0
- package/dist/esm/OwnerId.d.ts.map +1 -0
- package/dist/esm/OwnerId.js +33 -0
- package/dist/esm/OwnerId.js.map +1 -0
- package/dist/esm/Projection.d.ts +29 -0
- package/dist/esm/Projection.d.ts.map +1 -0
- package/dist/esm/Projection.js +13 -0
- package/dist/esm/Projection.js.map +1 -0
- package/dist/esm/RedactedLogger.d.ts +121 -0
- package/dist/esm/RedactedLogger.d.ts.map +1 -0
- package/dist/esm/RedactedLogger.js +445 -0
- package/dist/esm/RedactedLogger.js.map +1 -0
- package/dist/esm/Redaction.d.ts +350 -0
- package/dist/esm/Redaction.d.ts.map +1 -0
- package/dist/esm/Redaction.js +1584 -0
- package/dist/esm/Redaction.js.map +1 -0
- package/dist/esm/SqlConsensus.d.ts +44 -0
- package/dist/esm/SqlConsensus.d.ts.map +1 -0
- package/dist/esm/SqlConsensus.js +252 -0
- package/dist/esm/SqlConsensus.js.map +1 -0
- package/dist/esm/SqlJournal.d.ts +173 -0
- package/dist/esm/SqlJournal.d.ts.map +1 -0
- package/dist/esm/SqlJournal.js +1858 -0
- package/dist/esm/SqlJournal.js.map +1 -0
- package/dist/esm/StepFact.d.ts +66 -0
- package/dist/esm/StepFact.d.ts.map +1 -0
- package/dist/esm/StepFact.js +50 -0
- package/dist/esm/StepFact.js.map +1 -0
- package/dist/esm/index.d.ts +95 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +95 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/JournalInternalFault.d.ts +37 -0
- package/dist/esm/internal/JournalInternalFault.d.ts.map +1 -0
- package/dist/esm/internal/JournalInternalFault.js +28 -0
- package/dist/esm/internal/JournalInternalFault.js.map +1 -0
- package/dist/esm/migrations/0001_initial.d.ts +15 -0
- package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
- package/dist/esm/migrations/0001_initial.js +32 -0
- package/dist/esm/migrations/0001_initial.js.map +1 -0
- package/dist/esm/migrations/0002_checkpoints.d.ts +27 -0
- package/dist/esm/migrations/0002_checkpoints.d.ts.map +1 -0
- package/dist/esm/migrations/0002_checkpoints.js +38 -0
- package/dist/esm/migrations/0002_checkpoints.js.map +1 -0
- package/dist/esm/migrations/0003_startup_index.d.ts +15 -0
- package/dist/esm/migrations/0003_startup_index.d.ts.map +1 -0
- package/dist/esm/migrations/0003_startup_index.js +18 -0
- package/dist/esm/migrations/0003_startup_index.js.map +1 -0
- package/dist/esm/migrations/0004_dedup.d.ts +15 -0
- package/dist/esm/migrations/0004_dedup.d.ts.map +1 -0
- package/dist/esm/migrations/0004_dedup.js +38 -0
- package/dist/esm/migrations/0004_dedup.js.map +1 -0
- package/dist/esm/migrations/0005_run_event_type.d.ts +15 -0
- package/dist/esm/migrations/0005_run_event_type.d.ts.map +1 -0
- package/dist/esm/migrations/0005_run_event_type.js +18 -0
- package/dist/esm/migrations/0005_run_event_type.js.map +1 -0
- package/dist/esm/migrations/0006_consensus.d.ts +22 -0
- package/dist/esm/migrations/0006_consensus.d.ts.map +1 -0
- package/dist/esm/migrations/0006_consensus.js +69 -0
- package/dist/esm/migrations/0006_consensus.js.map +1 -0
- package/dist/esm/test/Notifying.d.ts +65 -0
- package/dist/esm/test/Notifying.d.ts.map +1 -0
- package/dist/esm/test/Notifying.js +62 -0
- package/dist/esm/test/Notifying.js.map +1 -0
- package/dist/esm/test/TestJournal.d.ts +43 -0
- package/dist/esm/test/TestJournal.d.ts.map +1 -0
- package/dist/esm/test/TestJournal.js +27 -0
- package/dist/esm/test/TestJournal.js.map +1 -0
- package/docs/README.md +164 -0
- package/docs/api.md +639 -0
- package/docs/concepts/compaction.md +157 -0
- package/docs/concepts/idempotency.md +127 -0
- package/docs/concepts/owner-fence.md +124 -0
- package/docs/concepts/redaction.md +218 -0
- package/docs/concepts/state-event-authority.md +159 -0
- package/docs/concepts/two-channels.md +167 -0
- package/docs/guides/commit-state-and-entry.md +114 -0
- package/docs/guides/compact-a-run.md +134 -0
- package/docs/guides/fold-a-projection.md +106 -0
- package/docs/guides/read-a-run.md +139 -0
- package/docs/guides/redact-log-output.md +94 -0
- package/docs/guides/testing.md +124 -0
- package/docs/guides/write-lifecycle-events.md +110 -0
- package/docs/installation.md +133 -0
- package/docs/quickstart.md +143 -0
- package/docs/troubleshooting.md +214 -0
- package/package.json +263 -3
- package/src/CallFact.ts +117 -0
- package/src/Consensus.ts +683 -0
- package/src/EngineEvent.ts +823 -0
- package/src/ExecutionFact.ts +433 -0
- package/src/Journal.ts +688 -0
- package/src/JournalEvent.ts +654 -0
- package/src/JournalGeneration.ts +77 -0
- package/src/JournalMetrics.ts +89 -0
- package/src/Migrations.ts +62 -0
- package/src/OwnerId.ts +42 -0
- package/src/Projection.ts +31 -0
- package/src/RedactedLogger.ts +483 -0
- package/src/Redaction.ts +1784 -0
- package/src/SqlConsensus.ts +344 -0
- package/src/SqlJournal.ts +2732 -0
- package/src/StepFact.ts +69 -0
- package/src/index.ts +109 -0
- package/src/internal/JournalInternalFault.ts +40 -0
- package/src/migrations/0001_initial.ts +41 -0
- package/src/migrations/0002_checkpoints.ts +46 -0
- package/src/migrations/0003_startup_index.ts +19 -0
- package/src/migrations/0004_dedup.ts +43 -0
- package/src/migrations/0005_run_event_type.ts +19 -0
- package/src/migrations/0006_consensus.ts +83 -0
- package/src/test/Notifying.ts +101 -0
- package/src/test/TestJournal.ts +52 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite-backed logical journal with durable and lossy channels.
|
|
3
|
+
*
|
|
4
|
+
* Lossy telemetry events remain optimistic until the single scoped writer
|
|
5
|
+
* commits them, so a process crash can lose accepted-but-unwritten telemetry.
|
|
6
|
+
* Lifecycle events use `emitDurable` and return after commit, except inside
|
|
7
|
+
* `transact`, where their savepoint completes before the outer commit.
|
|
8
|
+
*
|
|
9
|
+
* Governing design: `packages/smithers/flows/journal/docs/concepts/two-channels.md`.
|
|
10
|
+
* Prior-art decision: `packages/smithers/flows/sync/docs/concepts/replay-then-follow.md`.
|
|
11
|
+
*
|
|
12
|
+
* The replay-then-follow stream follows Effect's `EventJournal` and OpenCode's
|
|
13
|
+
* upstream event stream design. The bounded send queue deliberately deviates
|
|
14
|
+
* from their synchronous durable writes by reserving a provisional per-run
|
|
15
|
+
* sequence before admission. Both channels finalize canonical order at commit.
|
|
16
|
+
* SQLite retry and transaction behavior comes through `@smthrs/database`.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
*/
|
|
20
|
+
import { DurableWriter } from "@smthrs/database/DurableWriter";
|
|
21
|
+
import * as Effect from "effect/Effect";
|
|
22
|
+
import * as Layer from "effect/Layer";
|
|
23
|
+
import * as Scope from "effect/Scope";
|
|
24
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
25
|
+
import { Consensus } from "./Consensus.ts";
|
|
26
|
+
import { Journal, JournalError, type OverflowPolicy, type Service } from "./Journal.ts";
|
|
27
|
+
import { RunId, type Seq } from "./JournalEvent.ts";
|
|
28
|
+
import * as Redaction from "./Redaction.ts";
|
|
29
|
+
/**
|
|
30
|
+
* Automatic checkpoint-and-compact policy for the SQL journal.
|
|
31
|
+
*
|
|
32
|
+
* Disabled unless set on {@link SqlJournalOptions}. Once a run's committed
|
|
33
|
+
* entry count reaches `entryThreshold`, the journal asks `capture` for the
|
|
34
|
+
* caller's replay state at the run's durable tail, writes it as a checkpoint
|
|
35
|
+
* at that sequence, and compacts the entries strictly below it.
|
|
36
|
+
*
|
|
37
|
+
* Both channels run the policy after their allocation permit is free. Lossy
|
|
38
|
+
* commits fork scoped maintenance so the sole queue consumer keeps draining;
|
|
39
|
+
* durable emits await their attempt. `flush` awaits registered maintenance.
|
|
40
|
+
* `capture` may read or emit without blocking unrelated allocation. A capture is interrupted
|
|
41
|
+
* after 30 seconds so caller code cannot wedge journal admission indefinitely.
|
|
42
|
+
*
|
|
43
|
+
* A failed or refused attempt (a live stream behind the boundary, a capture
|
|
44
|
+
* failure) is logged at warning, damped for `entryThreshold`
|
|
45
|
+
* further committed entries, and never surfaced to the emit that triggered
|
|
46
|
+
* it.
|
|
47
|
+
*
|
|
48
|
+
* @category models
|
|
49
|
+
* @since 0.1.0
|
|
50
|
+
*/
|
|
51
|
+
export interface CompactionPolicy {
|
|
52
|
+
readonly entryThreshold: number;
|
|
53
|
+
readonly capture: (runId: RunId, upTo: Seq) => Effect.Effect<unknown, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* SQL journal queue and batching options.
|
|
57
|
+
*
|
|
58
|
+
* @category models
|
|
59
|
+
* @since 0.1.0
|
|
60
|
+
*/
|
|
61
|
+
export interface SqlJournalOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Bound on the number of ENTRIES held in two places at once: the lossy
|
|
64
|
+
* admission queue, where `overflow` decides what happens when it is full,
|
|
65
|
+
* and the sliding `changes` buffer, where a slow subscriber silently loses
|
|
66
|
+
* the entries that fall out of it.
|
|
67
|
+
*
|
|
68
|
+
* It bounds entries, not bytes. Set {@link SqlJournalOptions.maxEntryBytes}
|
|
69
|
+
* to bound the size of one entry as well; with it unset a handful of very
|
|
70
|
+
* large payloads is still the memory bill.
|
|
71
|
+
*/
|
|
72
|
+
readonly capacity: number;
|
|
73
|
+
/** Policy applied when the lossy admission queue is full. */
|
|
74
|
+
readonly overflow: OverflowPolicy;
|
|
75
|
+
/** Entries the queued writer commits per transaction. */
|
|
76
|
+
readonly batchSize?: number | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Upper bound on the in-process source-event index, the map that answers
|
|
79
|
+
* producer idempotency from memory.
|
|
80
|
+
*
|
|
81
|
+
* The index is a cache, never the authority, and a MISS costs a receipt, not
|
|
82
|
+
* correctness. On a miss for an explicit producer sequence the entry is
|
|
83
|
+
* admitted optimistically without any read: `emitLossy` returns `Accepted`
|
|
84
|
+
* where a resident entry would have returned `Duplicate`, and the insert
|
|
85
|
+
* collapses onto the committed row through the unique index
|
|
86
|
+
* `(run_id, source_id, source_seq)` rather than doubling it. A CHANGED retry
|
|
87
|
+
* behind an evicted entry therefore surfaces `idempotency_conflict` from
|
|
88
|
+
* `flush`, not from the emit. See `admitFromIndex` for why the read is gone:
|
|
89
|
+
* `emitLossy` is called from inside other write transactions, and the
|
|
90
|
+
* pre-admission SELECT deadlocked `@smthrs/agent`'s exit flush against the
|
|
91
|
+
* engine's own writer, measured at over 120 s versus about half a second
|
|
92
|
+
* without it.
|
|
93
|
+
*
|
|
94
|
+
* Bounding the cache keeps startup decode and resident memory O(bound) rather
|
|
95
|
+
* than O(total events ever written), mirroring Temporal's refusal to hold
|
|
96
|
+
* unbounded history in a shard (`service/history`). The separate
|
|
97
|
+
* sequence-floor maps start empty and grow only with runs and producers this
|
|
98
|
+
* layer instance touches; they are lazy, not governed by this bound.
|
|
99
|
+
*
|
|
100
|
+
* Idempotency compares canonical persisted JSON after redaction. Two inputs
|
|
101
|
+
* that redact to the same value are therefore the same event, and JSON's
|
|
102
|
+
* encoding intentionally treats `NaN` and `null` as the same `null` value.
|
|
103
|
+
*/
|
|
104
|
+
readonly sourceEventCache?: number | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Largest single entry the journal admits, measured in UTF-8 bytes of the
|
|
107
|
+
* encoded `payload` plus `meta`.
|
|
108
|
+
*
|
|
109
|
+
* Unset by default, which means unbounded: `capacity` bounds how MANY entries
|
|
110
|
+
* the admission queue and the `changes` buffer hold, never how large one is,
|
|
111
|
+
* so without this a handful of multi-megabyte payloads is the memory bill,
|
|
112
|
+
* and every one of them is replayed to each sync subscriber and time-travel
|
|
113
|
+
* consumer on every read. Set it where the journal is fed by untrusted or
|
|
114
|
+
* unbounded producers.
|
|
115
|
+
*
|
|
116
|
+
* The bound is checked after encoding and BEFORE any sequence is allocated or
|
|
117
|
+
* anything is queued, so a refused entry costs no sequence and leaves no gap.
|
|
118
|
+
* An entry over the bound fails `invalid_event`.
|
|
119
|
+
*/
|
|
120
|
+
readonly maxEntryBytes?: number | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Scrub applied to every `payload` and `meta` before it is encoded for
|
|
123
|
+
* persistence.
|
|
124
|
+
*
|
|
125
|
+
* Journal rows are permanent and are replayed verbatim to sync subscribers
|
|
126
|
+
* and time-travel consumers, so a credential that reaches `payload_json` is
|
|
127
|
+
* a durable, broadly readable leak. Redaction therefore defaults to
|
|
128
|
+
* `Redaction.make()`; pass `Redaction.makeNoop()` to persist payloads
|
|
129
|
+
* verbatim by choice.
|
|
130
|
+
*/
|
|
131
|
+
readonly redact?: Redaction.Redactor | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Automatic checkpoint-and-compact policy. Off by default: without it the
|
|
134
|
+
* journal never deletes an entry, and checkpointing stays a caller-driven
|
|
135
|
+
* `checkpoint` / `compact` call.
|
|
136
|
+
*/
|
|
137
|
+
readonly compaction?: CompactionPolicy | undefined;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Constructs the SQL journal over the context's SQL client, durable writer,
|
|
141
|
+
* and consensus strategy.
|
|
142
|
+
*
|
|
143
|
+
* `emitLossy` validates and admits telemetry to the non-blocking queue;
|
|
144
|
+
* `emitDurable` allocates and commits inside the database transaction, fenced
|
|
145
|
+
* through `Consensus.guard` in that same transaction.
|
|
146
|
+
*
|
|
147
|
+
* @category constructors
|
|
148
|
+
* @since 1.0.0
|
|
149
|
+
*/
|
|
150
|
+
export declare const make: (options: SqlJournalOptions) => Effect.Effect<Service, JournalError, Consensus | DurableWriter | SqlClient.SqlClient | Scope.Scope>;
|
|
151
|
+
/**
|
|
152
|
+
* Provides the SQL journal over an explicitly injected consensus strategy.
|
|
153
|
+
*
|
|
154
|
+
* The strategy in context arbitrates the owner fence: `emitDurable`,
|
|
155
|
+
* `checkpoint`, and `compact` join its `guard` inside their write
|
|
156
|
+
* transaction. Provide the SAME strategy instance to every service that must
|
|
157
|
+
* agree on ownership — `RunStore.layerWith` in particular — because
|
|
158
|
+
* `Consensus.layerLocal` keeps its leases per layer build.
|
|
159
|
+
*
|
|
160
|
+
* @category layers
|
|
161
|
+
* @since 1.0.0
|
|
162
|
+
*/
|
|
163
|
+
export declare const layerWith: (options: SqlJournalOptions) => Layer.Layer<Journal, JournalError, Consensus | DurableWriter | SqlClient.SqlClient>;
|
|
164
|
+
/**
|
|
165
|
+
* Provides the SQL journal fenced by the database-backed strategy,
|
|
166
|
+
* `SqlConsensus`, over the same client. Use {@link layerWith} to inject a
|
|
167
|
+
* different strategy.
|
|
168
|
+
*
|
|
169
|
+
* @category layers
|
|
170
|
+
* @since 0.1.0
|
|
171
|
+
*/
|
|
172
|
+
export declare const layer: (options: SqlJournalOptions) => Layer.Layer<Journal, JournalError, DurableWriter | SqlClient.SqlClient>;
|
|
173
|
+
//# sourceMappingURL=SqlJournal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlJournal.d.ts","sourceRoot":"","sources":["../../src/SqlJournal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAA8B,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAI1F,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAOrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EASL,OAAO,EACP,YAAY,EAGZ,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,cAAc,CAAA;AACrB,OAAO,EAKL,KAAK,EACL,KAAK,GAAG,EAGT,MAAM,mBAAmB,CAAA;AAK1B,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAM3C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;CAC/E;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;IACjC,yDAAyD;IACzD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3C;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAA;IAChD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACnD;AA+WD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,GACf,SAAS,iBAAiB,KACzB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,CAqlEjG,CAAA;AAEJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GACpB,SAAS,iBAAiB,KACzB,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC,SAAS,CAC/C,CAAA;AAEtC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAChB,SAAS,iBAAiB,KACzB,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC,SAAS,CACb,CAAA"}
|