From 2e2f7a151e5e182f55d560470cd4903b21978b77 Mon Sep 17 00:00:00 2001 From: mountain Date: Fri, 24 Nov 2023 16:30:47 +0900 Subject: [PATCH] =?UTF-8?q?tavern=20ccu=20=EB=A9=94=ED=8A=B8=EB=A6=AD=20?= =?UTF-8?q?=EC=88=98=EC=A7=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/tavern.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/tavern.go b/core/tavern.go index 9e92fa6..859af1a 100644 --- a/core/tavern.go +++ b/core/tavern.go @@ -14,6 +14,7 @@ import ( "repositories.action2quare.com/ayo/gocommon" "repositories.action2quare.com/ayo/gocommon/flagx" "repositories.action2quare.com/ayo/gocommon/logger" + "repositories.action2quare.com/ayo/gocommon/metric" "repositories.action2quare.com/ayo/gocommon/session" "repositories.action2quare.com/ayo/gocommon/wshandler" @@ -79,6 +80,7 @@ func New(context context.Context, wsh *wshandler.WebsocketHandler) (*Tavern, err } func (tv *Tavern) Cleanup() { + metric.ConcurrentUser.Set(0) tv.mongoClient.Close() } @@ -136,6 +138,7 @@ func (tv *Tavern) LeaveChannel(ctx wshandler.ApiCallContext) { } func (tv *Tavern) ClientConnected(conn *websocket.Conn, callby *wshandler.Sender) { + metric.ConcurrentUser.Add(1) tv.redison.Del(tv.redison.Context(), callby.Accid.Hex()) _, err := tv.redison.JSONSet(callby.Accid.Hex(), "$", bson.M{"_ts": time.Now().UTC().Unix()}) if err != nil { @@ -144,6 +147,7 @@ func (tv *Tavern) ClientConnected(conn *websocket.Conn, callby *wshandler.Sender } func (tv *Tavern) ClientDisconnected(msg string, callby *wshandler.Sender) { + metric.ConcurrentUser.Add(-1) tv.redison.Del(tv.redison.Context(), callby.Accid.Hex()).Result() }