mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-08-17 13:51:21 +03:00
remote: add Query.Missing serializer
This commit is contained in:
parent
c841f93b69
commit
d18a014103
@ -78,9 +78,6 @@ deriving via GenericArbitrary GCAction
|
||||
deriving via GenericArbitrary GCOptions
|
||||
instance Arbitrary GCOptions
|
||||
|
||||
deriving via GenericArbitrary GCResult
|
||||
instance Arbitrary GCResult
|
||||
|
||||
-- * Handshake
|
||||
|
||||
deriving via GenericArbitrary WorkerMagic
|
||||
@ -94,6 +91,8 @@ deriving via GenericArbitrary TrustedFlag
|
||||
deriving via GenericArbitrary WorkerOp
|
||||
instance Arbitrary WorkerOp
|
||||
|
||||
-- ** Request
|
||||
|
||||
instance Arbitrary (Some StoreRequest) where
|
||||
arbitrary = oneof
|
||||
[ Some <$> (AddToStore <$> arbitrary <*> arbitrary <*> arbitrary <*> pure RepairMode_DontRepair)
|
||||
@ -121,3 +120,11 @@ instance Arbitrary (Some StoreRequest) where
|
||||
, pure $ Some SyncWithGC
|
||||
, Some <$> (VerifyStore <$> arbitrary <*> arbitrary)
|
||||
]
|
||||
|
||||
-- ** Reply
|
||||
|
||||
deriving via GenericArbitrary GCResult
|
||||
instance Arbitrary GCResult
|
||||
|
||||
deriving via GenericArbitrary Missing
|
||||
instance Arbitrary Missing
|
||||
|
@ -92,6 +92,8 @@ module System.Nix.Store.Remote.Serializer
|
||||
, buildResult
|
||||
-- *** GCResult
|
||||
, gcResult
|
||||
-- *** Missing
|
||||
, missing
|
||||
) where
|
||||
|
||||
import Control.Monad.Except (MonadError, throwError, )
|
||||
@ -1341,6 +1343,7 @@ data ReplySError
|
||||
| ReplySError_PrimPut SError
|
||||
| ReplySError_DerivationOutput SError
|
||||
| ReplySError_GCResult SError
|
||||
| ReplySError_Missing SError
|
||||
| ReplySError_Realisation SError
|
||||
| ReplySError_RealisationWithId SError
|
||||
deriving (Eq, Ord, Generic, Show)
|
||||
@ -1453,3 +1456,23 @@ gcResult = mapErrorS ReplySError_GCResult $ Serializer
|
||||
putS int gcResultBytesFreed
|
||||
putS (int @Word64) 0 -- obsolete
|
||||
}
|
||||
|
||||
missing
|
||||
:: HasStoreDir r
|
||||
=> NixSerializer r ReplySError Missing
|
||||
missing = mapErrorS ReplySError_Missing $ Serializer
|
||||
{ getS = do
|
||||
missingWillBuild <- getS (hashSet storePath)
|
||||
missingWillSubstitute <- getS (hashSet storePath)
|
||||
missingUnknownPaths <- getS (hashSet storePath)
|
||||
missingDownloadSize <- getS int
|
||||
missingNarSize <- getS int
|
||||
|
||||
pure Missing{..}
|
||||
, putS = \Missing{..} -> do
|
||||
putS (hashSet storePath) missingWillBuild
|
||||
putS (hashSet storePath) missingWillSubstitute
|
||||
putS (hashSet storePath) missingUnknownPaths
|
||||
putS int missingDownloadSize
|
||||
putS int missingNarSize
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import System.Nix.Build (BuildResult)
|
||||
import System.Nix.StorePath (HasStoreDir(..), StorePath)
|
||||
import System.Nix.Store.Remote.Serializer
|
||||
import System.Nix.Store.Remote.Types.GC (GCResult)
|
||||
import System.Nix.Store.Remote.Types.Query.Missing (Missing)
|
||||
import System.Nix.Store.Remote.Types.ProtoVersion (HasProtoVersion)
|
||||
|
||||
-- | Get @NixSerializer@ for some type @a@
|
||||
@ -29,6 +30,9 @@ instance StoreReply BuildResult where
|
||||
instance StoreReply GCResult where
|
||||
getReplyS = gcResult
|
||||
|
||||
instance StoreReply Missing where
|
||||
getReplyS = missing
|
||||
|
||||
instance StoreReply StorePath where
|
||||
getReplyS = mapPrimE storePath
|
||||
|
||||
|
@ -151,6 +151,7 @@ spec = parallel $ do
|
||||
|
||||
describe "StoreReply" $ do
|
||||
prop "GCResult" $ roundtripSReader @StoreDir gcResult
|
||||
prop "Missing" $ roundtripSReader @StoreDir missing
|
||||
|
||||
restrictProtoVersion :: ProtoVersion -> Some StoreRequest -> Bool
|
||||
restrictProtoVersion v (Some (BuildPaths _ _)) | v < ProtoVersion 1 30 = False
|
||||
|
Loading…
Reference in New Issue
Block a user