remote: align GC(Options|Result) record field naming

This commit is contained in:
sorki 2023-12-07 08:37:29 +01:00
parent 77fe9f9acd
commit c841f93b69
4 changed files with 23 additions and 23 deletions

View File

@ -234,9 +234,9 @@ deleteSpecific paths = do
putInt (0::Int) putInt (0::Int)
putInt (0::Int) putInt (0::Int)
getSocketIncremental $ do getSocketIncremental $ do
gcResult_deletedPaths <- getPathsOrFail storeDir gcResultDeletedPaths <- getPathsOrFail storeDir
gcResult_bytesFreed <- getInt gcResultBytesFreed <- getInt
-- TODO: who knows -- TODO: obsolete
_ :: Int <- getInt _ :: Int <- getInt
pure GCResult{..} pure GCResult{..}

View File

@ -1101,10 +1101,10 @@ storeRequest = Serializer
pure $ Some (BuildDerivation path drv buildMode') pure $ Some (BuildDerivation path drv buildMode')
WorkerOp_CollectGarbage -> mapGetE $ do WorkerOp_CollectGarbage -> mapGetE $ do
gcOptions_operation <- getS enum gcOptionsOperation <- getS enum
gcOptions_pathsToDelete <- getS (hashSet storePath) gcOptionsPathsToDelete <- getS (hashSet storePath)
gcOptions_ignoreLiveness <- getS bool gcOptionsIgnoreLiveness <- getS bool
gcOptions_maxFreed <- getS int gcOptionsMaxFreed <- getS int
-- obsolete fields -- obsolete fields
Control.Monad.forM_ [0..(2 :: Word8)] Control.Monad.forM_ [0..(2 :: Word8)]
$ pure $ getS (int @Word8) $ pure $ getS (int @Word8)
@ -1238,10 +1238,10 @@ storeRequest = Serializer
Some (CollectGarbage GCOptions{..}) -> mapPutE $ do Some (CollectGarbage GCOptions{..}) -> mapPutE $ do
putS workerOp WorkerOp_CollectGarbage putS workerOp WorkerOp_CollectGarbage
putS enum gcOptions_operation putS enum gcOptionsOperation
putS (hashSet storePath) gcOptions_pathsToDelete putS (hashSet storePath) gcOptionsPathsToDelete
putS bool gcOptions_ignoreLiveness putS bool gcOptionsIgnoreLiveness
putS int gcOptions_maxFreed putS int gcOptionsMaxFreed
-- obsolete fields -- obsolete fields
Control.Monad.forM_ [0..(2 :: Word8)] Control.Monad.forM_ [0..(2 :: Word8)]
$ pure $ putS int (0 :: Word8) $ pure $ putS int (0 :: Word8)
@ -1444,12 +1444,12 @@ gcResult
=> NixSerializer r ReplySError GCResult => NixSerializer r ReplySError GCResult
gcResult = mapErrorS ReplySError_GCResult $ Serializer gcResult = mapErrorS ReplySError_GCResult $ Serializer
{ getS = do { getS = do
gcResult_deletedPaths <- getS (hashSet storePath) gcResultDeletedPaths <- getS (hashSet storePath)
gcResult_bytesFreed <- getS int gcResultBytesFreed <- getS int
Control.Monad.void $ getS (int @Word64) -- obsolete Control.Monad.void $ getS (int @Word64) -- obsolete
pure GCResult{..} pure GCResult{..}
, putS = \GCResult{..} -> do , putS = \GCResult{..} -> do
putS (hashSet storePath) gcResult_deletedPaths putS (hashSet storePath) gcResultDeletedPaths
putS int gcResult_bytesFreed putS int gcResultBytesFreed
putS (int @Word64) 0 -- obsolete putS (int @Word64) 0 -- obsolete
} }

View File

@ -24,24 +24,24 @@ data GCAction
-- | Garbage collector operation options -- | Garbage collector operation options
data GCOptions = GCOptions data GCOptions = GCOptions
{ -- | Operation { -- | Operation
gcOptions_operation :: GCAction gcOptionsOperation :: GCAction
-- | If set, then reachability from the roots is ignored (unused) -- | If set, then reachability from the roots is ignored (unused)
, gcOptions_ignoreLiveness :: Bool , gcOptionsIgnoreLiveness :: Bool
-- | Paths to delete for @GCAction_DeleteSpecific@ -- | Paths to delete for @GCAction_DeleteSpecific@
, gcOptions_pathsToDelete :: HashSet StorePath , gcOptionsPathsToDelete :: HashSet StorePath
-- | Stop after `gcOptions_maxFreed` bytes have been freed -- | Stop after `gcOptions_maxFreed` bytes have been freed
, gcOptions_maxFreed :: Word64 , gcOptionsMaxFreed :: Word64
} deriving (Eq, Generic, Ord, Show) } deriving (Eq, Generic, Ord, Show)
-- | Result of the garbage collection operation -- | Result of the garbage collection operation
data GCResult = GCResult data GCResult = GCResult
{ -- | Depending on the action, the GC roots, { -- | Depending on the action, the GC roots,
-- or the paths that would be or have been deleted -- or the paths that would be or have been deleted
gcResult_deletedPaths :: HashSet StorePath gcResultDeletedPaths :: HashSet StorePath
-- | The number of bytes that would be or was freed for -- | The number of bytes that would be or was freed for
-- --
-- - @GCAction_ReturnDead@ -- - @GCAction_ReturnDead@
-- - @GCAction_DeleteDead@ -- - @GCAction_DeleteDead@
-- - @GCAction_DeleteSpecific@ -- - @GCAction_DeleteSpecific@
, gcResult_bytesFreed :: Word64 , gcResultBytesFreed :: Word64
} deriving (Eq, Generic, Ord, Show) } deriving (Eq, Generic, Ord, Show)

View File

@ -297,6 +297,6 @@ spec_protocol = Hspec.around withNixDaemon $
removeFile $ mconcat [ tempRootsDir, "/", entry ] removeFile $ mconcat [ tempRootsDir, "/", entry ]
GCResult{..} <- deleteSpecific (HS.fromList [path]) GCResult{..} <- deleteSpecific (HS.fromList [path])
gcResult_deletedPaths `shouldBe` HS.fromList [path] gcResultDeletedPaths `shouldBe` HS.fromList [path]
gcResult_bytesFreed `shouldBe` 4 gcResultBytesFreed `shouldBe` 4