From b0de7ec02eb1936e90541cb1f3d29694b8211905 Mon Sep 17 00:00:00 2001 From: Hubert Grochowski Date: Mon, 21 Aug 2023 19:11:50 +0200 Subject: [PATCH] martian/context: store id as string This does not require to convert id on every call to ID(). --- internal/martian/context.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/martian/context.go b/internal/martian/context.go index 1bdee27e..b2b38fb0 100644 --- a/internal/martian/context.go +++ b/internal/martian/context.go @@ -31,7 +31,7 @@ import ( // a single connection. type Context struct { session *Session - id uint64 + id string mu sync.RWMutex vals map[string]any @@ -186,7 +186,7 @@ func (ctx *Context) Session() *Session { // ID returns the context ID. func (ctx *Context) ID() string { - return strconv.FormatUint(ctx.id, 10) + return ctx.id } // Get takes key and returns the associated value from the context. @@ -255,6 +255,6 @@ func init() { func withSession(s *Session) *Context { return &Context{ session: s, - id: nextID.Add(1), + id: strconv.FormatUint(nextID.Add(1), 10), } }