mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-09-01 20:18:26 +00:00
Compare commits
4
Commits
smp-web
...
f/ntf-logs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eea37ede4 | ||
|
|
6c1e1f18d4 | ||
|
|
c71f0d7beb | ||
|
|
52aa164f9a |
@@ -1865,11 +1865,13 @@ withWork c doWork getWork action =
|
|||||||
noWork = liftIO $ noWorkToDo doWork
|
noWork = liftIO $ noWorkToDo doWork
|
||||||
notifyErr err e = atomically $ writeTBQueue (subQ c) ("", "", AEvt SAEConn $ ERR $ err $ show e)
|
notifyErr err e = atomically $ writeTBQueue (subQ c) ("", "", AEvt SAEConn $ ERR $ err $ show e)
|
||||||
|
|
||||||
withWorkItems :: AgentClient -> TMVar () -> (DB.Connection -> IO (Either StoreError [Either StoreError a])) -> (NonEmpty a -> AM ()) -> AM ()
|
withWorkItems :: String -> AgentClient -> TMVar () -> (DB.Connection -> IO (Either StoreError [Either StoreError a])) -> (NonEmpty a -> AM ()) -> AM ()
|
||||||
withWorkItems c doWork getWork action = do
|
withWorkItems str c doWork getWork action = do
|
||||||
withStore' c getWork >>= \case
|
withStore' c getWork >>= \case
|
||||||
|
Right [] -> noWork
|
||||||
Right rs -> do
|
Right rs -> do
|
||||||
let (errs, items) = partitionEithers rs
|
let (errs, items) = partitionEithers rs
|
||||||
|
liftIO $ print $ "withWorkItems - " <> str <> " - length items = " <> show (length items) <> ", length errs = " <> show (length errs)
|
||||||
case L.nonEmpty items of
|
case L.nonEmpty items of
|
||||||
Just items' -> action items'
|
Just items' -> action items'
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ runNtfSupervisor :: AgentClient -> AM' ()
|
|||||||
runNtfSupervisor c = do
|
runNtfSupervisor c = do
|
||||||
ns <- asks ntfSupervisor
|
ns <- asks ntfSupervisor
|
||||||
forever $ do
|
forever $ do
|
||||||
|
liftIO $ print "#################### runNtfSupervisor - in forever loop"
|
||||||
cmd <- atomically . readTBQueue $ ntfSubQ ns
|
cmd <- atomically . readTBQueue $ ntfSubQ ns
|
||||||
handleErr . agentOperationBracket c AONtfNetwork waitUntilActive $
|
handleErr . agentOperationBracket c AONtfNetwork waitUntilActive $
|
||||||
runExceptT (processNtfCmd c cmd) >>= \case
|
runExceptT (processNtfCmd c cmd) >>= \case
|
||||||
@@ -196,13 +197,14 @@ withTokenServer action = lift getNtfToken >>= mapM_ (\NtfToken {ntfServer} -> ac
|
|||||||
runNtfWorker :: AgentClient -> NtfServer -> Worker -> AM ()
|
runNtfWorker :: AgentClient -> NtfServer -> Worker -> AM ()
|
||||||
runNtfWorker c srv Worker {doWork} =
|
runNtfWorker c srv Worker {doWork} =
|
||||||
forever $ do
|
forever $ do
|
||||||
|
liftIO $ print "#################### runNtfWorker - in forever loop"
|
||||||
waitForWork doWork
|
waitForWork doWork
|
||||||
ExceptT $ agentOperationBracket c AONtfNetwork throwWhenInactive $ runExceptT runNtfOperation
|
ExceptT $ agentOperationBracket c AONtfNetwork throwWhenInactive $ runExceptT runNtfOperation
|
||||||
where
|
where
|
||||||
runNtfOperation :: AM ()
|
runNtfOperation :: AM ()
|
||||||
runNtfOperation = do
|
runNtfOperation = do
|
||||||
ntfBatchSize <- asks $ ntfBatchSize . config
|
ntfBatchSize <- asks $ ntfBatchSize . config
|
||||||
withWorkItems c doWork (\db -> getNextNtfSubNTFActions db srv ntfBatchSize) $ \nextSubs -> do
|
withWorkItems "runNtfWorker" c doWork (\db -> getNextNtfSubNTFActions db srv ntfBatchSize) $ \nextSubs -> do
|
||||||
logInfo $ "runNtfWorker - length nextSubs = " <> tshow (length nextSubs)
|
logInfo $ "runNtfWorker - length nextSubs = " <> tshow (length nextSubs)
|
||||||
currTs <- liftIO getCurrentTime
|
currTs <- liftIO getCurrentTime
|
||||||
let (creates, checks, deletes, rotates) = splitActions currTs nextSubs
|
let (creates, checks, deletes, rotates) = splitActions currTs nextSubs
|
||||||
@@ -364,15 +366,18 @@ runNtfWorker c srv Worker {doWork} =
|
|||||||
|
|
||||||
runNtfSMPWorker :: AgentClient -> SMPServer -> Worker -> AM ()
|
runNtfSMPWorker :: AgentClient -> SMPServer -> Worker -> AM ()
|
||||||
runNtfSMPWorker c srv Worker {doWork} = forever $ do
|
runNtfSMPWorker c srv Worker {doWork} = forever $ do
|
||||||
|
ts <- liftIO getCurrentTime
|
||||||
|
liftIO $ print $ "#################### runNtfSMPWorker - in forever loop - ts = " <> show ts
|
||||||
waitForWork doWork
|
waitForWork doWork
|
||||||
ExceptT $ agentOperationBracket c AONtfNetwork throwWhenInactive $ runExceptT runNtfSMPOperation
|
ExceptT $ agentOperationBracket c AONtfNetwork throwWhenInactive $ runExceptT runNtfSMPOperation
|
||||||
where
|
where
|
||||||
runNtfSMPOperation :: AM ()
|
runNtfSMPOperation :: AM ()
|
||||||
runNtfSMPOperation = do
|
runNtfSMPOperation = do
|
||||||
ntfBatchSize <- asks $ ntfBatchSize . config
|
ntfBatchSize <- asks $ ntfBatchSize . config
|
||||||
withWorkItems c doWork (\db -> getNextNtfSubSMPActions db srv ntfBatchSize) $ \nextSubs -> do
|
withWorkItems "runNtfSMPWorker" c doWork (\db -> getNextNtfSubSMPActions db srv ntfBatchSize) $ \nextSubs -> do
|
||||||
logInfo $ "runNtfSMPWorker - length nextSubs = " <> tshow (length nextSubs)
|
logInfo $ "runNtfSMPWorker - length nextSubs = " <> tshow (length nextSubs)
|
||||||
let (creates, deletes) = splitActions nextSubs
|
let (creates, deletes) = splitActions nextSubs
|
||||||
|
liftIO $ print $ "runNtfSMPWorker - length nextSubs = " <> tshow (length nextSubs) <> ", length creates = " <> tshow (length creates) <> ", length deletes = " <> tshow (length deletes)
|
||||||
retrySubActions c creates createNotifierKeys
|
retrySubActions c creates createNotifierKeys
|
||||||
retrySubActions c deletes deleteNotifierKeys
|
retrySubActions c deletes deleteNotifierKeys
|
||||||
splitActions :: NonEmpty (NtfSubSMPAction, NtfSubscription) -> ([NtfSubscription], [NtfSubscription])
|
splitActions :: NonEmpty (NtfSubSMPAction, NtfSubscription) -> ([NtfSubscription], [NtfSubscription])
|
||||||
|
|||||||
Reference in New Issue
Block a user