Sync / foldkit-sync/journal

ReactionOptions

interface · packages/sync/src/serverJournal.ts:137

interface ReactionOptions<AppModel, On, Appends, R> {
  readonly name: string
  readonly on: MessageSet<AppModel, any, On, any>
  readonly appends?: MessageSet<AppModel, any, Appends, any>
  readonly timeout?: Duration.Input
  readonly attempts?: number
  readonly parkAfter?: Duration.Input
  readonly run: (
    trigger: Trigger<On>,
  ) => Effect.Effect<ReadonlyArray<NoInfer<Appends>> | void, unknown, R>
}

Members

ReactionOptions.name

property · packages/sync/src/serverJournal.ts:139

readonly name: string

Part of every run's key, so renaming it is a new reaction. Letters, digits, _ and -, at most 64; unique in the document.

ReactionOptions.on

property · packages/sync/src/serverJournal.ts:141

readonly on: MessageSet<AppModel, any, On, any>

The committed Messages it runs after: a set of the contract's own application.

ReactionOptions.appends

property · packages/sync/src/serverJournal.ts:143

readonly appends?: MessageSet<AppModel, any, Appends, any>

The server-only Messages it may append, checked on every answer. Without it, it appends nothing.

ReactionOptions.timeout

property · packages/sync/src/serverJournal.ts:145

readonly timeout?: Duration.Input

How long one run may take before it counts as failed. Default 10 seconds.

ReactionOptions.attempts

property · packages/sync/src/serverJournal.ts:147

readonly attempts?: number

A failing run is parked once it has failed this many times, and for at least parkAfter. Default 8.

ReactionOptions.parkAfter

property · packages/sync/src/serverJournal.ts:149

readonly parkAfter?: Duration.Input

How long a run must have been failing before it may be parked, so an outage parks nothing. Default one hour.

ReactionOptions.run

property · packages/sync/src/serverJournal.ts:154

readonly run: (
  trigger: Trigger<On>,
) => Effect.Effect<ReadonlyArray<NoInfer<Appends>> | void, unknown, R>

One external call, or none, and the Messages to append, at most 16. It may run again with the same trigger: pass trigger.key to the provider.