Sync / foldkit-durable

JournalService

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

function JournalService<
  Operation,
  Snapshot,
  Principal,
  OperationEncoded = unknown,
>(
  key?: string,
): Context.ServiceClass<
  JournalShape<Operation, Snapshot, Principal, OperationEncoded>,
  string,
  JournalShape<Operation, Snapshot, Principal, OperationEncoded>
>

The journal as a service, so an application composes it with Effect.provide instead of threading the shape through its own wiring. Pass the codec's Encoded type as the fourth parameter when it is not unknown, and use a distinct key if the application runs more than one journal.

Prefer Journal.define. The type arguments here are supplied at each use site and nothing checks them against the layer that satisfied the tag, so yield* JournalService<SomeOtherOperation, ...>('app/Journal') compiles and hands back a journal typed as something it is not — the key is the only real identity. Journal.define fixes the parameters once and derives both the tag and its layer from them.