Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Jan 24, 2025
1 parent 7137c43 commit 02faead
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/request_id_header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/**
* Copyright 2025 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,7 +21,7 @@ const randIdForProcess = randomBytes(8).readBigUint64LE(0).toString();
const X_GOOG_SPANNER_REQUEST_ID_HEADER = 'x-goog-spanner-request-id';

class AtomicCounter {
private backingBuffer: Uint32Array;
private readonly backingBuffer: Uint32Array;

constructor(initialValue?: number) {
this.backingBuffer = new Uint32Array(
Expand Down Expand Up @@ -53,13 +53,15 @@ class AtomicCounter {
}
}

const REQUEST_HEADER_VERSION = 1;

function craftRequestId(
nthClientId: number,
channelId: number,
nthRequest: number,
attempt: number
) {
return `1.${randIdForProcess}.${nthClientId}.${channelId}.${nthRequest}.${attempt}`;
return `${REQUEST_HEADER_VERSION}.${randIdForProcess}.${nthClientId}.${channelId}.${nthRequest}.${attempt}`;
}

const nthClientId = new AtomicCounter();
Expand Down Expand Up @@ -162,7 +164,6 @@ class XGoogRequestHeaderInterceptor {
const prefixesToIgnore: string[] = this.prefixesToIgnore || [];
for (i = 0; i < prefixesToIgnore.length; i++) {
const prefix = prefixesToIgnore[i];
// console.log(`prefix: ${prefix}\nmethod: ${method}`);
if (method.startsWith(prefix)) {
next(metadata);
return;
Expand Down

0 comments on commit 02faead

Please sign in to comment.