effect-state-machine
ReferenceGenerated API

MachineEngine API

Generated reference for the public MachineEngine module.

effect-state-machine API


effect-state-machine API / MachineEngine

MachineEngine

configuration

Config

Defined in: packages/core/src/MachineEngine.ts:34

Worker and polling policy shared by every machine run beneath one engine Layer.

Details

Lease durations apply to machine-message and activity claims, pollIntervalMillis controls idle store polling, and activityWorkerCount bounds the local activity workers created per instance. Omitted fields use engine defaults.

Since

0.2.0

Properties

machineLeaseMillis?

readonly optional machineLeaseMillis?: number

Defined in: packages/core/src/MachineEngine.ts:35

activityLeaseMillis?

readonly optional activityLeaseMillis?: number

Defined in: packages/core/src/MachineEngine.ts:36

pollIntervalMillis?

readonly optional pollIntervalMillis?: number

Defined in: packages/core/src/MachineEngine.ts:37

activityWorkerCount?

readonly optional activityWorkerCount?: number

Defined in: packages/core/src/MachineEngine.ts:38

layers

layer()

layer(config?): Layer<MachineEngine, never, MachineStore>

Defined in: packages/core/src/MachineEngine.ts:357

Builds a machine-engine Layer from the supplied MachineStore.MachineStore service.

When to use

Use with a persistent or custom aggregate-store Layer when machine state must outlive the current process or browser page.

Gotchas

This Layer still requires MachineStore.MachineStore; provide the adapter at the application boundary and share the resulting Layer for every run that must observe the same aggregates.

Parameters

config?

Config = {}

Returns

Layer<MachineEngine, never, MachineStore>

See

layerMemory for an explicit process-local composition.

Since

0.2.0


layerMemory()

layerMemory(config?): Layer<MachineEngine>

Defined in: packages/core/src/MachineEngine.ts:381

Explicit volatile composition of the unified engine with a process-local aggregate store.

One Layer value owns one shared in-memory database. It uses the same persisted document, timer, mailbox, lease, and activity protocol as every restart-capable adapter.

When to use

Use for tests, examples, and applications that deliberately accept process-local persistence.

Gotchas

Building this Layer again creates a new empty database. Reuse one Layer value when separate runs must address the same machine instance.

Parameters

config?

Config = {}

Returns

Layer<MachineEngine>

See

layer for composing a restart-capable store.

Since

0.2.0

Other

MachineEngine

Defined in: packages/core/src/MachineEngineService.ts:10

Package-private service key; the focused MachineEngine module owns the public re-export.

Extends

  • Shape<"effect-state-machine/MachineEngine", Service, this>

Constructors

Constructor

new MachineEngine(_): MachineEngine

Defined in: node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/Context.d.ts:115

Parameters
_

never

Returns

MachineEngine

Inherited from

Context.Service<MachineEngine, Service>()( "effect-state-machine/MachineEngine", ).constructor

running

run()

run<InputSchema, StateSchema, EventSchema, States>(definition, input): RunEffect<StateSchema, EventSchema, States>

Defined in: packages/core/src/MachineEngine.ts:395

Runs or resumes a machine definition through the supplied MachineEngine service.

Details

This is the data-first counterpart of a definition's run method. The returned Effect retains the definition-derived state, event, completion, failure, Scope, and application-service types.

Type Parameters

InputSchema

InputSchema extends Top

StateSchema

StateSchema extends TaggedSchema

EventSchema

EventSchema extends TaggedSchema

States

States extends Readonly<{ [Current in string]: StateConfig<Type<(...)>, Type<(...)>, Current> }>

Parameters

definition

MachineDefinition<InputSchema, StateSchema, EventSchema, States>

input

Type<InputSchema>

Returns

RunEffect<StateSchema, EventSchema, States>

Since

0.2.0