ntf: use common function for differentiating temporary errors (#1333)

This commit is contained in:
spaced4ndy
2024-09-25 18:40:59 +01:00
committed by GitHub
parent 1afa0206a5
commit 41e1b2bd39
@@ -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