wip, merge storage

This commit is contained in:
Dmitry Zuykov 2025-05-16 11:25:36 +03:00
parent 98a97ba55f
commit af295029ec
2 changed files with 23 additions and 1 deletions

View File

@ -403,7 +403,16 @@ ncqStorageRun ncq@NCQStorage{..} = flip runContT pure do
makeMerge = do
me <- ContT $ withAsync $ untilStopped do
micropause @'Seconds 10
debug "MERGE THREAD"
req <- readTVarIO ncqMergeReq
when (req > 0) do
debug $ "STARTED MERGE" <+> pretty req
try @_ @SomeException (ncqStorageMergeStep ncq) >>= \case
Right{} -> none
Left e -> err ("MERGE ERROR:" <+> viaShow e)
atomically $ writeTVar ncqMergeReq 0
link me
pure me

View File

@ -221,6 +221,19 @@ main = do
pure nil
entry $ bindMatch "ncq:merge" $ \syn -> lift do
tcq <- case syn of
[ isOpaqueOf @TCQ -> Just tcq ] -> do
pure tcq
e -> throwIO $ BadFormException @C (mkList e)
ncq <- getNCQ tcq
ncqStorageMerge ncq
pure nil
entry $ bindMatch "ncq:close" $ nil_ \case
[ isOpaqueOf @TCQ -> Just tcq ] -> lift do
ncq <- getNCQ tcq