Optional
acquireThe maximum timeout in milliseconds for acquiring a lock. This is an optional parameter that sets a limit on how long the system should wait to acquire a lock before timing out. It's used in conjunction with the locking mechanism.
A factory function that creates an instance of the actor.
The unique identifier of the actor.
An optional parameter that provides a previously persisted snapshot of the actor's state, allowing for state restoration.
actorCreator: (id, snapshot) => {
if (snapshot)
throw new Error(
`The subject=${id} already exists so it cannot be initiated`,
);
return createCloudOrchestrationActor(statemachine.logic, {
version: statemachine.version,
name: param.name,
id,
snapshot,
input: initEvent.context,
middleware: {
onState: param.onOrchestrationState,
onCloudEvent: param.onCloudEvent,
},
});
}
// Or
actorCreator: (id, snapshot) => {
// From xstate
return createActor(createMachine({...}), {
id,
snapshot,
})
}
A factory function that creates an instance of the actor.
The unique identifier of the actor.
Optional
snapshot: Snapshot<unknown>An optional parameter that provides a previously persisted snapshot of the actor's state, allowing for state restoration.
actorCreator: (id, snapshot) => {
if (snapshot)
throw new Error(
`The subject=${id} already exists so it cannot be initiated`,
);
return createCloudOrchestrationActor(statemachine.logic, {
version: statemachine.version,
name: param.name,
id,
snapshot,
input: initEvent.context,
middleware: {
onState: param.onOrchestrationState,
onCloudEvent: param.onCloudEvent,
},
});
}
// Or
actorCreator: (id, snapshot) => {
// From xstate
return createActor(createMachine({...}), {
id,
snapshot,
})
}
The unique identifier for the actor. This ID is used to differentiate between multiple instances and is crucial for tracking and managing the state of each actor.
Optional
locking?: "write" | "read-write"Specifies the locking mode for the actor's persistence operations.
The storage manager responsible for persisting the state of the orchestration.
Should implement the ILockableStorageManager
interface for concurrent access control.
This is governed by the npm package unified-serverless-storage
see here.
Note: The storageManager read method must return the snapshot, as JSON string, of the machine and the write function must be able to recieve and save the data passed to it as string. This string is the snapshot of the machine in JSON string format.
// Example storage manager implementation.
storageManager: myLockableStorageManager
Generated using TypeDoc
Defines the structure for the input parameters required by the
withPersistance
function. This interface is crucial for setting up a persistent actor in an XState context, providing necessary details like identification, storage management, and actor creation logic.