Sync / foldkit-durable/core

Journal

namespace · packages/durable/src/service.ts:86

const Journal = { layer, metrics, define }

Its type

type Journal<
  Operation,
  Snapshot,
  Principal,
  OperationEncoded = unknown,
> = JournalShape<Operation, Snapshot, Principal, OperationEncoded>

A durable journal; see journal.ts. Declared here beside the Journal namespace, since a type and a const of one name must come from one module.

Members

Journal.layer

function · packages/durable/src/service.ts:50

layer<
  Operation,
  Snapshot,
  Principal,
  OperationEncoded = unknown,
  SnapshotEncoded = unknown,
>(
  options: JournalStoreOptions<
    Operation,
    Snapshot,
    Principal,
    OperationEncoded,
    SnapshotEncoded
  >,
  key?: string,
): Layer.Layer<
  JournalShape<Operation, Snapshot, Principal, OperationEncoded>,
  JournalError | UnsupportedJournalVersionError,
  SqlClient.SqlClient
>

The journal as a layer over the SqlClient it is given, under the default service key. Provide the driver to the layer, not to an effect, and the database opens and closes with it.

Journal.metrics

const · packages/durable/src/journal.ts:49

metrics: {
  appends: Metric.Counter<number>
  compactions: Metric.Counter<number>
  effectRuns: Metric.Counter<number>
  effectRunsCoalesced: Metric.Counter<number>
}

Counters an application can scrape.

Journal.define

function · packages/durable/src/service.ts:105

define<Operation, Snapshot, Principal, OperationEncoded = unknown>(
  key: string,
): JournalDefinition<Operation, Snapshot, Principal, OperationEncoded>

Declares a journal's service key and its type parameters once, and returns the tag and the layer constructor that agree on them.

ts
const Todos = Journal.define<Operation, Snapshot, Principal>('app/Todos')
const live = Todos.layer(options).pipe(Layer.provide(WasmClient.layerMemory({})))
const journal = yield* Todos.tag