Sync / foldkit-sync/journal

JournalExchangeOptions

interface · packages/sync/src/journal.ts:40

interface JournalExchangeOptions<Message, Shared, Principal> {
  readonly sync: Sync<Message, Shared>
  readonly journal: Journal<Operation, Shared, Principal, Operation>
  readonly principal: Principal
  readonly settle?: Effect.Effect<void, unknown> | undefined
  readonly opens?: Effect.Effect<boolean> | undefined
  readonly admit?:
    | ((
        operation: Operation,
      ) => AuthorizeDecision | Effect.Effect<AuthorizeDecision, unknown>)
    | undefined
  readonly limit?: number | undefined
}

Members

JournalExchangeOptions.sync

property · packages/sync/src/journal.ts:42

readonly sync: Sync<Message, Shared>

The document's contract: its codecs, and the snapshot a checkpoint encodes.

JournalExchangeOptions.journal

property · packages/sync/src/journal.ts:47

readonly journal: Journal<Operation, Shared, Principal, Operation>

The journal made from sync.journalContract(), which orders and keeps the document. One that takes any input, or only operations, is accepted.

JournalExchangeOptions.principal

property · packages/sync/src/journal.ts:52

readonly principal: Principal

Who is exchanging, as the transport established it. The journal's authorize reads it; a refused operation is reported as rejected.

JournalExchangeOptions.settle

property · packages/sync/src/journal.ts:58

readonly settle?: Effect.Effect<void, unknown> | undefined

Runs after each exchange's appends and before the reply is read: apply what committed to another store, through journal.recover. It runs on every exchange, so a write that failed is tried again on the next.

JournalExchangeOptions.opens

property · packages/sync/src/journal.ts:64

readonly opens?: Effect.Effect<boolean> | undefined

Whether the connection may open the document at all, to read it or to change it: a principal outside its readers. Refused, every exchange fails, and nothing is read or appended.

JournalExchangeOptions.admit

property · packages/sync/src/journal.ts:74

readonly admit?:
  | ((
      operation: Operation,
    ) => AuthorizeDecision | Effect.Effect<AuthorizeDecision, unknown>)
  | undefined

Whether an operation may be appended, decided before the journal sees it, by what the transport established rather than by the document: a principal that may only read, or a rule that reads the rows an edit names, which cannot run under the journal's lock (foldkit-guard/sync). true admits; a refusal is rejected by the operation's id, with its reason when it gives one. One that fails fails the exchange, as the journal failing does. The journal's own authorize is where a rule about the document goes.

JournalExchangeOptions.limit

property · packages/sync/src/journal.ts:78

readonly limit?: number | undefined

The most committed operations one reply carries; a replica further behind asks again. Default 500.