Skip to content

Commit

Permalink
Add stable uuid generation for playback
Browse files Browse the repository at this point in the history
  • Loading branch information
RickWinter committed Jul 29, 2021
1 parent 5e40dde commit b5b2983
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sdk/internal/recording/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,20 @@ func (r *Recording) Now() time.Time {
func (r *Recording) UUID() uuid.UUID {
r.initRandomSource()

return uuid.FromSource(r.src)
if r.Mode == Live {
return uuid.New()
}

u := uuid.UUID{}
// Set all bits to randomly (or pseudo-randomly) chosen values.
// math/rand.Read() is no-fail so we omit any error checking.
rnd := rand.New(r.src)
rnd.Read(u[:])
u[8] = (u[8] | 0x40) & 0x7F // u.setVariant(ReservedRFC4122)

var version byte = 4
u[6] = (u[6] & 0xF) | (version << 4) // u.setVersion(4)
return u
}

// GenerateAlphaNumericID will generate a recorded random alpha numeric id
Expand Down

0 comments on commit b5b2983

Please sign in to comment.