tavern ccu 메트릭 수집
This commit is contained in:
@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user