@ 支付/ 核心
从当前域名事实和演员权限来计算可用的作品. 一个步骤 操作者拥有持久性、交易、最后业务招生和外部 打电话 承接验证了状态/投入,评价了"卫兵"并引用了一次.
import { actor, caseType, createBackgroundRuntime, createEngine, stepsOf } from '@affordance/core'
import { z } from 'zod'
const State = z.object({ ein: z.string().nullable() })
const step = stepsOf(State, actor<{ id: string }>())
const definition = caseType({
name: 'deal', state: State,
steps: [
step({
name: 'record-ein', input: z.object({ ein: z.string() }),
handler: async ({ reference, actor, input, state }) => {
const saved = await deals.recordEin(reference, actor, input)
return { ...state, ein: saved.ein } // Already persisted; evidence only.
},
}),
step({
name: 'notify',
handler: async ({ reference, executionId }) => {
await notifications.send(reference, { executionId })
// No return: success without a diff journal.
},
}),
],
})
// Bind an authoritative loader using your adapter, e.g. storage.bindCase(definition, { load }).
const runtime = createBackgroundRuntime()
const engine = createEngine({
storage, caseTypes: [binding],
operations: { journalTimeoutMs: 1000 },
launch: { runtime, leaseMs: 60_000 },
})
const result = await engine.run(caseId, 'record-ein', { actor, input: { ein: '12-3456789' } })
// result.journal.status: 'skipped' | 'recorded' | 'failed'
const { executionId } = await engine.launch(caseId, 'notify', { actor })
const execution = await engine.getExecution(executionId)
// running | completed | unresolved | resolved; null for unknown IDs and ordinary runs.
await runtime.drain() // Stop new launches and await owned tasks during application shutdown.
run 等待处理器的补全和设定的可选日记尝试. launch
在运行时间拥有剩余工作时返回处理器条目后。 双用
同样的 Promise<State | void> 合同和处理器上下文。 没有注射
寄存器、交易回调或补全包. undefined 跳过
日记; 有效国家制作 observed diff,即使没有改变.
返回国从未成为目前的个案国。 随后读取使用约束.
丢弃的处理器出错不会从 run;承诺效果可能
已经存在。 启动的处理器错误显示为未解决状态 。 无效
参数和日记失败不会使处理器成功完成或
重试业务代码 。 日记超时包括适配器获取等.
已经启动的写作可能会在原执行ID下完成后.
提供的运行时间是一个长寿的节点进程,并保留未完成的任务 活到他们安顿下来 它无法活下来处理死亡或没有服务器的主机 请求后冻结。 这样的主机需要一个独立自主的运行时间 真正的操作员入场承认。 单是排队接受是不够的. 没有重播、心跳、自动重试、补偿或恢复工作者.
发射所有权不包括同一情况下的其他参与发射. 过期会留下一个块直到应用程序/操作器对齐:
await engine.resolveExecution(executionId, { actor, reason: 'Reconciled with provider' })
决议不是取消。 租赁不设栅栏或提供商写作; 旧的处理器在过期或解析后仍然可以写作. 普通运行和 不相关的作者不参加。 主办方必须授权地位和解决.
安全演员归属默认为字符串演员或字符串 actor.id,否则
无效。 配置 operations.actorIdentity 用于另一个字符串身份。 请求
输入和认证对象不通过此管道进行分录。 定义大小写
作为预定日记投影的状态;在和
过后. 保存证书和无关数据 从计划.
此断取β去除 execute, (中文(简体) ), executeNonAtomic,交易
处理器寄存器和原子适配器端口。 框架期刊/租赁数据
未迁移。 见 结构。 。 。 .