Skip to content

Commit d7671ec

Browse files
authored
feat(spanner): make randIDForProcess hexadecimal in x-goog-spanner-request-id (googleapis#11546)
Implements a new requirement that randIDForProcess should be a hexadecimal value with the format specifier "%016x". Fixes googleapis#11545
1 parent a8f16ef commit d7671ec

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

spanner/request_id_header.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func init() {
4646
if err != nil {
4747
panic(err)
4848
}
49-
randIDForProcess = r64.String()
49+
randIDForProcess = fmt.Sprintf("%016x", r64.Uint64())
5050
}
5151

5252
// Please bump this version whenever this implementation

spanner/request_id_header_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package spanner
1616

1717
import (
1818
"context"
19+
"encoding/hex"
1920
"encoding/json"
2021
"fmt"
2122
"math"
@@ -1925,3 +1926,13 @@ func TestRequestIDHeader_SingleUseReadOnly_ExecuteStreamingSql_UnavailableDuring
19251926
t.Fatalf("RequestID streaming segments mismatch: got - want +\n%s", diff)
19261927
}
19271928
}
1929+
1930+
func TestRequestID_randIDForProcessIsHexadecimal(t *testing.T) {
1931+
decoded, err := hex.DecodeString(randIDForProcess)
1932+
if err != nil {
1933+
t.Fatal(err)
1934+
}
1935+
if len(decoded) == 0 {
1936+
t.Fatal("Expected a non-empty decoded result")
1937+
}
1938+
}

0 commit comments

Comments
 (0)