only reconnect client on temporary errors in single subscription too (not currently used) (#616)

* only reconnect client on temporary errors in single subscription too (not currently used)

* refactor
This commit is contained in:
Evgeny Poberezkin
2023-01-18 22:03:43 +00:00
committed by GitHub
parent 14cb88e725
commit 4f4b4f7eee
+4 -2
View File
@@ -611,9 +611,11 @@ subscribeQueue c rq@RcvQueue {connId, server, rcvPrivateKey, rcvId} = do
modifyTVar' (subscrConns c) $ S.insert connId
RQ.addQueue rq $ pendingSubs c
r <- withLogClient c server rcvId "SUB" $ \smp ->
liftIO (runExceptT (subscribeSMPQueue smp rcvPrivateKey rcvId) >>= processSubResult c rq)
liftIO $ runExceptT (subscribeSMPQueue smp rcvPrivateKey rcvId) >>= processSubResult c rq
case r of
Left e -> reconnectServer c server >> throwError (protocolClientError SMP (B.unpack $ strEncode server) e)
Left e -> do
when (temporaryClientError e) $ reconnectServer c server
throwError (protocolClientError SMP (B.unpack $ strEncode server) e)
_ -> pure ()
processSubResult :: AgentClient -> RcvQueue -> Either ProtocolClientError () -> IO (Either ProtocolClientError ())