ChainGraph API Documentation / @badaitech/chaingraph-channel / types / ChannelStats
Interface: ChannelStats
Defined in: types/ChannelStats.d.ts:15
Statistics for channel monitoring and debugging.
Provides insight into channel state, performance, and resource usage. Used for:
- Backpressure decisions
- Performance monitoring
- Debugging slow consumers
- Resource usage tracking
Extended by
Properties
bufferSize
bufferSize:
number
Defined in: types/ChannelStats.d.ts:32
Number of items currently in the buffer.
For InMemoryChannel: In-memory buffer size For DBOSChannel: Number of unread items in database (estimate)
Example
const stats = channel.getStats()
if (stats.bufferSize > 1000) {
await channel.send(value) // Wait
} else {
channel.send(value) // Continue
}currentPosition
currentPosition:
number
Defined in: types/ChannelStats.d.ts:54
Current sequence position (next value will be at this position).
Useful for:
- Tracking total values sent
- Offset management
- Resuming from specific position
extra?
optionalextra:Record<string,unknown>
Defined in: types/ChannelStats.d.ts:76
Implementation-specific additional statistics.
Examples:
- InMemoryChannel: { subscriberPositions: [0, 5, 10], slowestPosition: 0 }
- DBOSChannel: { workflowId: '...', remoteOffset: 1000, lastSync: timestamp }
- TRPCChannel: { connectionState: 'connected', latency: 50 }
implementation
implementation:
string
Defined in: types/ChannelStats.d.ts:67
Channel implementation type.
Useful for:
- Runtime type checking
- Metrics tagging
- Debugging
isClosed
isClosed:
boolean
Defined in: types/ChannelStats.d.ts:58
Whether the channel is closed.
subscriberCount
subscriberCount:
number
Defined in: types/ChannelStats.d.ts:45
Number of active subscribers currently consuming from the channel.
For InMemoryChannel: Local subscribers only For DBOSChannel: Subscribers on this server only (not global)
Example
const stats = channel.getStats()
console.log(`${stats.subscriberCount} active consumers`)