All files / packages/topic/src/writer producer-id.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

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        3x 3x 3x 3x    
// Generates a unique producer id when the caller does not supply one. The
// producer id + seqNo form the server-side dedup key, so it must be stable for
// the lifetime of one writer but distinct across writers.
export function generateProducerId(): string {
	let processId = process.pid
	let currentTime = new Date().getTime()
	let randomSuffix = Math.floor(Math.random() * 1_000_000)
	return `producer-${processId}-${currentTime}-${randomSuffix}`
}