All files / packages/topic/src index.ts

60% Statements 3/5
100% Branches 0/0
60% Functions 3/5
60% Lines 3/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                  1x   1x           1x              
import { Driver } from '@ydbjs/core'
 
import {
	type TopicReader,
	type TopicReaderOptions,
	type TopicTxReader,
	createTopicReader,
	createTopicTxReader,
} from './reader/index.js'
import type { TX } from './tx.js'
import {
	type TopicWriter,
	type TopicWriterOptions,
	createTopicTxWriter,
	createTopicWriter,
} from './writer/index.js'
 
export interface TopicClient {
	createReader(options: TopicReaderOptions): TopicReader
	createTxReader(tx: TX, options: TopicReaderOptions): TopicTxReader
	createWriter(options: TopicWriterOptions): TopicWriter
	createTxWriter(tx: TX, options: Omit<TopicWriterOptions, 'tx'>): TopicWriter
}
 
export function topic(driver: Driver): TopicClient {
	return {
		createReader(options) {
			return createTopicReader(driver, options)
		},
		createTxReader(tx, options) {
			return createTopicTxReader(tx, driver, options)
		},
		createWriter(options) {
			return createTopicWriter(driver, options)
		},
		createTxWriter(tx, options) {
			return createTopicTxWriter(tx, driver, options)
		},
	}
}