mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
Bidirectional worker op
Use dummy enum variants to fill the gaps so the Enum instance works Co-Authored-By: Dan Bornside <dan.bornside@gmail.com>
This commit is contained in:
parent
a2397f5b3f
commit
ca5faba4ba
@ -53,75 +53,59 @@ workerMagic2 = 0x6478696f
|
||||
defaultSockPath :: String
|
||||
defaultSockPath = "/nix/var/nix/daemon-socket/socket"
|
||||
|
||||
data WorkerOp =
|
||||
IsValidPath
|
||||
| HasSubstitutes
|
||||
| QueryReferrers
|
||||
| AddToStore
|
||||
| AddTextToStore
|
||||
| BuildPaths
|
||||
| EnsurePath
|
||||
| AddTempRoot
|
||||
| AddIndirectRoot
|
||||
| SyncWithGC
|
||||
| FindRoots
|
||||
| SetOptions
|
||||
| CollectGarbage
|
||||
| QuerySubstitutablePathInfo
|
||||
| QueryDerivationOutputs
|
||||
| QueryAllValidPaths
|
||||
| QueryFailedPaths
|
||||
| ClearFailedPaths
|
||||
| QueryPathInfo
|
||||
| QueryDerivationOutputNames
|
||||
| QueryPathFromHashPart
|
||||
| QuerySubstitutablePathInfos
|
||||
| QueryValidPaths
|
||||
| QuerySubstitutablePaths
|
||||
| QueryValidDerivers
|
||||
| OptimiseStore
|
||||
| VerifyStore
|
||||
| BuildDerivation
|
||||
| AddSignatures
|
||||
| NarFromPath
|
||||
| AddToStoreNar
|
||||
| QueryMissing
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
opNum :: WorkerOp -> Int
|
||||
opNum IsValidPath = 1
|
||||
opNum HasSubstitutes = 3
|
||||
opNum QueryReferrers = 6
|
||||
opNum AddToStore = 7
|
||||
opNum AddTextToStore = 8
|
||||
opNum BuildPaths = 9
|
||||
opNum EnsurePath = 10
|
||||
opNum AddTempRoot = 11
|
||||
opNum AddIndirectRoot = 12
|
||||
opNum SyncWithGC = 13
|
||||
opNum FindRoots = 14
|
||||
opNum SetOptions = 19
|
||||
opNum CollectGarbage = 20
|
||||
opNum QuerySubstitutablePathInfo = 21
|
||||
opNum QueryDerivationOutputs = 22
|
||||
opNum QueryAllValidPaths = 23
|
||||
opNum QueryFailedPaths = 24
|
||||
opNum ClearFailedPaths = 25
|
||||
opNum QueryPathInfo = 26
|
||||
opNum QueryDerivationOutputNames = 28
|
||||
opNum QueryPathFromHashPart = 29
|
||||
opNum QuerySubstitutablePathInfos = 30
|
||||
opNum QueryValidPaths = 31
|
||||
opNum QuerySubstitutablePaths = 32
|
||||
opNum QueryValidDerivers = 33
|
||||
opNum OptimiseStore = 34
|
||||
opNum VerifyStore = 35
|
||||
opNum BuildDerivation = 36
|
||||
opNum AddSignatures = 37
|
||||
opNum NarFromPath = 38
|
||||
opNum AddToStoreNar = 39
|
||||
opNum QueryMissing = 40
|
||||
|
||||
-- | Worker opcode
|
||||
--
|
||||
-- This type has gaps filled in so that the GHC builtin
|
||||
-- Enum instance lands on the right values.
|
||||
data WorkerOp
|
||||
= Reserved_0__ -- 0
|
||||
| IsValidPath -- 1
|
||||
| Reserved_2__ -- 2
|
||||
| HasSubstitutes -- 3
|
||||
| QueryPathHash -- 4 // obsolete
|
||||
| QueryReferences -- 5 // obsolete
|
||||
| QueryReferrers -- 6
|
||||
| AddToStore -- 7
|
||||
| AddTextToStore -- 8 // obsolete since 1.25, Nix 3.0. Use wopAddToStore
|
||||
| BuildPaths -- 9
|
||||
| EnsurePath -- 10 0xa
|
||||
| AddTempRoot -- 11 0xb
|
||||
| AddIndirectRoot -- 12 0xc
|
||||
| SyncWithGC -- 13 0xd
|
||||
| FindRoots -- 14 0xe
|
||||
| Reserved_15__ -- 15 0xf
|
||||
| ExportPath -- 16 0x10 // obsolete
|
||||
| Reserved_17__ -- 17 0x11
|
||||
| QueryDeriver -- 18 0x12 // obsolete
|
||||
| SetOptions -- 19 0x13
|
||||
| CollectGarbage -- 20 0x14
|
||||
| QuerySubstitutablePathInfo -- 21 0x15
|
||||
| QueryDerivationOutputs -- 22 0x16 // obsolete
|
||||
| QueryAllValidPaths -- 23 0x17
|
||||
| QueryFailedPaths -- 24 0x18
|
||||
| ClearFailedPaths -- 25 0x19
|
||||
| QueryPathInfo -- 26 0x1a
|
||||
| ImportPaths -- 27 0x1b // obsolete
|
||||
| QueryDerivationOutputNames -- 28 0x1c // obsolete
|
||||
| QueryPathFromHashPart -- 29 0x1d
|
||||
| QuerySubstitutablePathInfos -- 30 0x1e
|
||||
| QueryValidPaths -- 31 0x1f
|
||||
| QuerySubstitutablePaths -- 32 0x20
|
||||
| QueryValidDerivers -- 33 0x21
|
||||
| OptimiseStore -- 34 0x22
|
||||
| VerifyStore -- 35 0x23
|
||||
| BuildDerivation -- 36 0x24
|
||||
| AddSignatures -- 37 0x25
|
||||
| NarFromPath -- 38 0x26
|
||||
| AddToStoreNar -- 39 0x27
|
||||
| QueryMissing -- 40 0x28
|
||||
| QueryDerivationOutputMap -- 41 0x29
|
||||
| RegisterDrvOutput -- 42 0x2a
|
||||
| QueryRealisation -- 43 0x2b
|
||||
| AddMultipleToStore -- 44 0x2c
|
||||
| AddBuildLog -- 45 0x2d
|
||||
| BuildPathsWithResults -- 46 0x2e
|
||||
deriving (Bounded, Eq, Enum, Ord, Show, Read)
|
||||
|
||||
simpleOp :: WorkerOp -> MonadStore Bool
|
||||
simpleOp op = simpleOpArgs op $ pure ()
|
||||
@ -153,7 +137,7 @@ runOpArgsIO
|
||||
-> MonadStore ()
|
||||
runOpArgsIO op encoder = do
|
||||
|
||||
sockPut $ putInt $ opNum op
|
||||
sockPut $ putEnum op
|
||||
|
||||
soc <- asks storeSocket
|
||||
encoder (liftIO . sendAll soc)
|
||||
|
Loading…
Reference in New Issue
Block a user