From 41e1b2bd39ac64eb9b636be18f95c018424349fa Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Wed, 25 Sep 2024 21:40:59 +0400 Subject: [PATCH] ntf: use common function for differentiating temporary errors (#1333) --- src/Simplex/Messaging/Agent/NtfSubSupervisor.hs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs b/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs index 9a949eec4..96f14dfc3 100644 --- a/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs +++ b/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs @@ -370,7 +370,7 @@ runNtfSMPWorker c srv Worker {doWork} = forever $ do addRes (a, r_) (as, errs, rs) = case r_ of Right r -> (as, errs, (a, r) : rs) Left e - | tempErr e -> (a : as, errs, rs) + | temporaryOrHostError e -> (a : as, errs, rs) | otherwise -> (as, (a, e) : errs, rs) rescheduleAction :: TMVar () -> UTCTime -> UTCTime -> AM' Bool @@ -386,16 +386,10 @@ rescheduleAction doWork ts actionTs retryOnError :: AgentClient -> Text -> AM () -> (AgentErrorType -> AM ()) -> AgentErrorType -> AM () retryOnError c name loop done e = do logError $ name <> " error: " <> tshow e - if tempErr e + if temporaryOrHostError e then retryNetworkLoop c loop else done e -tempErr :: AgentErrorType -> Bool -tempErr = \case - BROKER _ NETWORK -> True - BROKER _ TIMEOUT -> True - _ -> False - retryNetworkLoop :: AgentClient -> AM () -> AM () retryNetworkLoop c loop = do atomically $ endAgentOperation c AONtfNetwork