From 3dda144b3a59ea6a8183433877ce69be6fd9bd73 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:50:45 +0400 Subject: [PATCH] sub stats --- src/Simplex/Messaging/Agent.hs | 6 ++++-- src/Simplex/Messaging/Agent/Client.hs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index c1d9d09e1..457e7d518 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -2173,13 +2173,15 @@ processSMPTransmissions c@AgentClient {subQ} (tSess@(_, srv, _), _v, sessId, ts) Left e -> notify' connId (ERR e) Right () -> pure () processSubOk :: RcvQueue -> TVar [ConnId] -> AM () - processSubOk rq@RcvQueue {connId} upConnIds = + processSubOk rq@RcvQueue {userId, connId} upConnIds = do atomically . whenM (isPendingSub connId) $ do addSubscription c rq modifyTVar' upConnIds (connId :) + atomically $ incSMPServerStat c userId srv connSubscribed 1 processSubErr :: RcvQueue -> SMPClientError -> AM () - processSubErr rq@RcvQueue {connId} e = do + processSubErr rq@RcvQueue {userId, connId} e = do atomically . whenM (isPendingSub connId) $ failSubscription c rq e + atomically $ incSMPServerStat c userId srv connSubErrs 1 lift $ notifyErr connId e isPendingSub connId = (&&) <$> hasPendingSubscription c connId <*> activeClientSession c tSess sessId notify' :: forall e m. (AEntityI e, MonadIO m) => ConnId -> AEvent e -> m () diff --git a/src/Simplex/Messaging/Agent/Client.hs b/src/Simplex/Messaging/Agent/Client.hs index a5e9e10bb..8b9532f6d 100644 --- a/src/Simplex/Messaging/Agent/Client.hs +++ b/src/Simplex/Messaging/Agent/Client.hs @@ -1395,6 +1395,7 @@ subscribeQueues c qs = do pure $ if prohibited then Left (rq, Left $ CMD PROHIBITED "subscribeQueues") else Right rq subscribeQueues_ :: Env -> TVar (Maybe SessionId) -> SMPClient -> NonEmpty RcvQueue -> IO (BatchResponses SMPClientError ()) subscribeQueues_ env session smp qs' = do + -- atomically $ incSMPServerStat c userId server connSubAttempts 1 -- ? use userId and server from the first queue? rs <- sendBatch subscribeSMPQueues smp qs' active <- atomically $