Run stores
Where a paused run waits between calls. Memory for tests, any key-value store, or Redis.
A paused run has to outlive the request that started it. The next call might come seconds
or days later, and on another serverless instance. So runs live in a run store, which
you pass to registerWorkflowTool or workflowRuns:
registerWorkflowTool(server, 'deploy', { runStore }, deploy)| store | from | for |
|---|---|---|
memoryRunStore() | @onedef/elicitation-workflow | tests, and a single long-lived server |
kvRunStore(store) | @onedef/elicitation-workflow | any key-value store with four methods, e.g. files |
redisRunStore(redis) | @onedef/elicitation-workflow/redis | serverless deploys |
Redis (serverless)
import { Redis } from '@upstash/redis'
import { redisRunStore } from '@onedef/elicitation-workflow/redis'
const runStore = redisRunStore(Redis.fromEnv(), {
prefix: 'deploys:', // default 'onedef:'
ttlSeconds: 60 * 60 * 24, // runs expire a day after their last write (default 7 days)
})Any client with the same few commands works. An @upstash/redis Redis fits as it is.
Any key-value store
kvRunStore keeps runs in a store that has get, put (with an atomic "only if absent"),
delete and list. The @onedef/store stores have exactly that shape, so files work like
this:
import { kvRunStore } from '@onedef/elicitation-workflow'
import { fsStore } from '@onedef/store/fs'
const runStore = kvRunStore(fsStore('.data')) // runs under .data/_runsThe "only if absent" write is what keeps two racing calls from both moving the same run.
Your own
A run store is TanStack Workflow's RunStore interface, so any store written for TanStack
Workflow works too.