ChainGraph API Documentation / @badaitech/chaingraph-channel / types / DBOSChannelConfig
Interface: DBOSChannelConfig
Defined in: types/ChannelConfig.d.ts:67
Configuration for DBOSChannel.
Extends
Properties
batchTimeoutMs?
optionalbatchTimeoutMs:number
Defined in: types/ChannelConfig.d.ts:195
Timeout for batch accumulation in milliseconds.
If batch doesn't reach consumerBatchSize within this time, it's flushed anyway.
Default
25cleanupStrategy?
optionalcleanupStrategy:BufferCleanupStrategy
Defined in: types/ChannelConfig.d.ts:28
Buffer cleanup strategy when maxBufferSize is reached.
- min-position: Keep items from slowest subscriber forward (fair to all)
- sliding-window: Always keep last N items (simple, may drop slow consumers)
- time-based: Remove items older than maxBufferAge
- none: No cleanup (unbounded growth)
Default
'min-position'Inherited from
BaseChannelConfig.cleanupStrategy
consumerBatchSize?
optionalconsumerBatchSize:number
Defined in: types/ChannelConfig.d.ts:186
Batch size for yielding to consumers.
DBOSChannel yields arrays of items for efficiency.
Default
100deduplication?
optionaldeduplication:boolean
Defined in: types/ChannelConfig.d.ts:135
Enable offset-based deduplication between history and real-time.
Prevents race condition where same event appears in both history query and real-time buffer. Uses max offset from history to filter real-time buffer.
Default
trueExample
// History: offsets [98, 99, 100]
// Buffer: offsets [100, 101, 102]
// Result: offsets [98, 99, 100, 101, 102] (no duplicate 100)fromOffset?
optionalfromOffset:number
Defined in: types/ChannelConfig.d.ts:146
Starting offset for reading from the stream (manual override).
Overrides lastN calculation. Useful for resuming from specific position.
- 0: Read from beginning
- N: Skip first N items
Default
undefined (use lastN or read all)lastN?
optionallastN:number
Defined in: types/ChannelConfig.d.ts:120
For 'history' mode: How many historical events to read.
- undefined or 0: Read ALL history from offset 0
- number > 0: Read last N events only
This enables "warm start" subscriptions where you want recent context without replaying the entire history.
Default
undefined (read all history)Examples
Read all history
readMode: 'history'
lastN: undefinedRead last 100 events
readMode: 'history'
lastN: 100maxBufferAge?
optionalmaxBufferAge:number
Defined in: types/ChannelConfig.d.ts:36
Maximum age of buffered items in milliseconds (for time-based cleanup).
Only used when cleanupStrategy is 'time-based'.
Default
60000 (1 minute)Inherited from
BaseChannelConfig.maxBufferAge
maxBufferSize?
optionalmaxBufferSize:number
Defined in: types/ChannelConfig.d.ts:17
Maximum buffer size (0 = unbounded)
When buffer exceeds this size, cleanup is triggered based on cleanupStrategy.
Default
1000 for InMemoryChannelDefault
0 for DBOSChannel (database-backed, no in-memory buffer limit)Inherited from
BaseChannelConfig.maxBufferSize
pgConnectionString?
optionalpgConnectionString:string
Defined in: types/ChannelConfig.d.ts:199
PostgreSQL connection string for LISTEN/NOTIFY.
pgPool?
optionalpgPool:unknown
Defined in: types/ChannelConfig.d.ts:203
PostgreSQL query pool for SELECT queries.
queryBatchSize?
optionalqueryBatchSize:number
Defined in: types/ChannelConfig.d.ts:178
Batch size for database reads.
Higher values reduce database queries but increase memory usage.
Default
1000readMode?
optionalreadMode:ReadMode
Defined in: types/ChannelConfig.d.ts:100
Read mode for stream consumption.
- 'history': Read history (all or last N), then continue real-time
- 'realtime': Skip history, start from current position
Default
'history'Examples
Read all history, then real-time
readMode: 'history'
lastN: undefinedRead last 50 events, then real-time
readMode: 'history'
lastN: 50Real-time only (skip history)
readMode: 'realtime'retry?
optionalretry:object
Defined in: types/ChannelConfig.d.ts:207
Retry configuration for transient failures.
backoffMultiplier?
optionalbackoffMultiplier:number
Backoff multiplier for exponential backoff.
Default
2initialDelay?
optionalinitialDelay:number
Initial retry delay in milliseconds.
Default
100maxAttempts?
optionalmaxAttempts:number
Maximum retry attempts for failed operations.
Default
3maxDelay?
optionalmaxDelay:number
Maximum retry delay in milliseconds.
Default
5000streamKey
streamKey:
string
Defined in: types/ChannelConfig.d.ts:80
Stream key within the workflow.
A workflow can have multiple streams (e.g., 'events', 'results', 'metrics').
toOffset?
optionaltoOffset:number
Defined in: types/ChannelConfig.d.ts:161
Ending offset for reading from the stream.
- undefined: Read until channel closed (infinite)
- N: Stop after reading offset N-1
Useful for reading specific ranges.
Default
undefined (infinite)Example
Read offsets 1000-1999
fromOffset: 1000
toOffset: 2000where()?
optionalwhere: (value) =>boolean
Defined in: types/ChannelConfig.d.ts:170
Client-side filter predicate.
Applied AFTER database query (not in SQL). Simple and flexible.
Parameters
value
any
Returns
boolean
Example
Filter by event type
where: (event) => event.type === 'PORT_UPDATED'workflowId
workflowId:
string
Defined in: types/ChannelConfig.d.ts:74
DBOS workflow UUID identifying the stream.
All servers reading/writing to the same workflowId + streamKey will be connected to the same distributed stream.