Kizaki
ReferenceInspire

Triggers, Effects, And Schedules

Declare synchronous hooks, retryable async work, and recurring jobs in Inspire.

Three constructs for work that follows data changes or runs on a clock. Each has distinct execution and failure semantics.

Triggers

A trigger runs synchronously within the mutation transaction. If the trigger function throws, the entire mutation rolls back.

entity Order {
  status: string,
  total:  int,

  @on(insert)        trigger validateOrder
  @on(update, status) trigger onStatusChange    // fires only when status changes
  @on(delete)        trigger onOrderDelete
}

Use triggers for derived data, invariants, and cache invalidation that must be transactionally consistent. Do not use triggers for slow or fallible external I/O.

Trigger Syntax

@on(<action>[, <field>]) trigger <functionName>
  • action: insert, update, or delete
  • field (optional, update only): fires only when that field changes

Effects

An effect runs asynchronously via a transactional outbox. The platform guarantees at-least-once delivery with configurable retry.

entity Order {
  status: string,

  @on(insert) effect sendOrderConfirmation {
    retries: 5,
    backoff: exponential(1s),
    timeout: 30s,
  }

  @on(update, status) effect sendStatusUpdate {
    retries: 3,
    backoff: linear(2s),
    timeout: 15s,
  }
}

Use effects for emails, notifications, webhooks, external API calls, and any retryable work.

Effect Syntax

@on(<action>[, <field>]) effect <functionName> {
  retries:  <int>,
  backoff:  exponential(<duration>) | linear(<duration>) | fixed(<duration>),
  timeout:  <duration>,
}
FieldDescription
retriesRetry attempts after the first failure
backoffDelay strategy between retries
timeoutMaximum execution time per attempt

Backoff strategies:

StrategyBehavior
exponential(1s)Doubles each attempt: 1s, 2s, 4s, 8s...
linear(2s)Increases by one step: 2s, 4s, 6s...
fixed(5s)Constant delay between attempts

Duration format: 30d, 24h, 5m, 30s.

Schedules

A schedule runs a server function on a cron schedule.

schedule dailyCleanup {
  cron:     "0 2 * * *",
  function: cleanupExpiredTokens,
  system:   "token_cleanup",
  timeout:  5m,
}

schedule weeklyDigest {
  cron:     "0 9 * * 1",
  function: sendWeeklyDigest,
  timeout:  10m,
}

Schedule Fields

FieldRequiredDescription
cronYesStandard five-field cron expression (UTC)
functionYesHandler function name
systemNoSystem role for elevated access
timeoutNoMaximum execution time

The platform uses FOR UPDATE SKIP LOCKED for at-most-once execution across instances.

How To Choose

NeedTool
Work must succeed with the write or roll backtrigger
Work can happen after the write, can be retriedeffect
Work runs on a clockschedule

Related guide: Background Work

On this page