DurableObject.Dsl.Extension

Copy Markdown View Source

Spark DSL extension defining the structure for Durable Objects.

This extension provides three sections:

  • state - Define state fields
  • handlers - Define RPC handlers
  • options - Configure lifecycle options

state

Define the state fields for this Durable Object

Nested DSLs

state.field

field name, type

A field in the Durable Object's state

Arguments

NameTypeDefaultDocs
nameatomThe name of the field
typeatomThe type of the field (for documentation)

Options

NameTypeDefaultDocs
defaultanyThe default value for the field

Introspection

Target: DurableObject.Dsl.Field

handlers

Define the handlers (RPC methods) for this Durable Object

Nested DSLs

handlers.handler

handler name

An RPC handler for the Durable Object

Arguments

NameTypeDefaultDocs
nameatomThe name of the handler

Options

NameTypeDefaultDocs
argslist(atom)[]List of argument names for the handler

Introspection

Target: DurableObject.Dsl.Handler

options

Configure lifecycle options

Options

NameTypeDefaultDocs
hibernate_afterpos_integer | :infinity300000Hibernate process after this many ms of inactivity (default: 5 minutes)
shutdown_afterpos_integer | :infinity | nilStop process after this many ms of inactivity (nil = never)
object_keys:strings | :atoms! | :atomsHow to convert string keys within field values when loading from JSON. :strings (default, no conversion), :atoms! (existing atoms only, raises otherwise), :atoms (creates atoms if needed).