All files / packages/topic/src partition-session.ts

100% Statements 17/17
100% Branches 2/2
100% Functions 7/7
100% Lines 17/17

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                                5225x       5225x       5225x       5225x       5225x       5225x                 5225x 5225x 5225x       185796x       2x               2x               1x       1568x       8x 8x 8x      
export class TopicPartitionSession {
	/**
	 * Partition session identifier.
	 */
	readonly partitionSessionId: bigint
	/**
	 * Partition identifier.
	 */
	readonly partitionId: bigint
	/**
	 * Topic path.
	 */
	readonly topicPath: string
	/**
	 * Partition offsets.
	 */
	partitionOffsets = { start: 0n, end: 0n }
	/**
	 * Offset of the last committed message from the partition.
	 */
	partitionCommittedOffset = 0n
	/**
	 * Flag indicating whether the session is currently active.
	 */
	#stopped = false
	/**
	 * Flag indicating whether the session has ended.
	 */
	#ended = false
	/**
	 * Partitions formed by the split/merge that ended this one (autopartitioning).
	 */
	#childPartitionIds: bigint[] = []
	/**
	 * Partitions merged with this one (autopartitioning).
	 */
	#adjacentPartitionIds: bigint[] = []
 
	/**
	 * Creates a new instance of TopicPartitionSession.
	 * @param partitionSessionId - The identifier of the partition session.
	 * @param partitionId - The identifier of the partition.
	 * @param topicPath - The path of the topic.
	 */
	constructor(partitionSessionId: bigint, partitionId: bigint, topicPath: string) {
		this.partitionSessionId = partitionSessionId
		this.partitionId = partitionId
		this.topicPath = topicPath
	}
 
	get isStopped(): boolean {
		return this.#stopped
	}
 
	get isEnded(): boolean {
		return this.#ended
	}
 
	/**
	 * Partitions formed by the split/merge that ended this one. Empty until the
	 * session ends (autopartitioning topics only).
	 */
	get childPartitionIds(): readonly bigint[] {
		return this.#childPartitionIds
	}
 
	/**
	 * Partitions merged with this one. Empty until the session ends
	 * (autopartitioning topics only).
	 */
	get adjacentPartitionIds(): readonly bigint[] {
		return this.#adjacentPartitionIds
	}
 
	stop(): void {
		this.#stopped = true
	}
 
	end(childPartitionIds: bigint[] = [], adjacentPartitionIds: bigint[] = []): void {
		this.#ended = true
		this.#childPartitionIds = childPartitionIds
		this.#adjacentPartitionIds = adjacentPartitionIds
	}
}