Make wop* an enum

This commit is contained in:
Emery Hemingway 2023-06-12 23:42:24 +01:00
parent 584c01ef08
commit a6aeaadf81
4 changed files with 52 additions and 41 deletions

View File

@ -1,4 +1,4 @@
version = "20230611"
version = "20230612"
author = "Emery Hemingway"
description = "Syndicated Nix Actor"
license = "Unlicense"

View File

@ -62,7 +62,9 @@ proc serveClient(facet: Facet; ds: Ref; store: ErisStore; client: Session) {.asy
await send(client, "0.0.0")
await sendWorkEnd(client)
while not client.socket.isClosed:
let wop = await recvWord(client.socket)
let
w = await recvWord(client.socket)
wop = WorkerOperation(w)
case wop
of wopAddToStore:
@ -147,7 +149,7 @@ proc serveClient(facet: Facet; ds: Ref; store: ErisStore; client: Session) {.asy
# all options from the client are ingored
else:
let msg = "unhandled worker op " & $wop.int
let msg = "unhandled worker op " & $wop
await sendNext(client, msg)
await sendWorkEnd(client)
close(client.socket)

View File

@ -94,7 +94,7 @@ proc connectDaemon(daemon: Session; socketPath: string) {.async.} =
proc queryMissing(daemon: Session; targets: StringSeq): Future[Missing] {.async.} =
var miss = Missing(targets: targets)
await send(daemon, wopQueryMissing)
await send(daemon, Word wopQueryMissing)
await send(daemon, miss.targets)
await recvWork(daemon)
miss.willBuild = await recvStringSet(daemon)
@ -106,7 +106,7 @@ proc queryMissing(daemon: Session; targets: StringSeq): Future[Missing] {.async.
proc queryPathInfo(daemon: Session; path: string): Future[LegacyPathAttrs] {.async.} =
var info: LegacyPathAttrs
await send(daemon, wopQueryPathInfo)
await send(daemon, Word wopQueryPathInfo)
await send(daemon, path)
await recvWork(daemon)
let valid = await recvWord(daemon)
@ -140,7 +140,7 @@ proc addToStore(daemon: Session; store: ErisStore; request: AddToStoreClientAttr
let
erisCap = parseCap(request.eris)
stream = newErisStream(store, erisCap)
await send(daemon, wopAddToStore)
await send(daemon, Word wopAddToStore)
await send(daemon, request.name)
await send(daemon, string request.`ca-method`)
await send(daemon, request.references)

View File

@ -32,41 +32,50 @@ const
STDERR_STOP_ACTIVITY* = 0x53544F50
STDERR_RESULT* = 0x52534C54
wopIsValidPath* = 1
wopHasSubstitutes* = 3
wopQueryReferrers* = 6
wopAddToStore* = 7
wopBuildPaths* = 9
wopEnsurePath* = 10
wopAddTempRoot* = 11
wopAddIndirectRoot* = 12
wopSyncWithGC* = 13
wopFindRoots* = 14
wopSetOptions* = 19
wopCollectGarbage* = 20
wopQuerySubstitutablePathInfo* = 21
wopQueryAllValidPaths* = 23
wopQueryFailedPaths* = 24
wopClearFailedPaths* = 25
wopQueryPathInfo* = 26
wopQueryPathFromHashPart* = 29
wopQuerySubstitutablePathInfos* = 30
wopQueryValidPaths* = 31
wopQuerySubstitutablePaths* = 32
wopQueryValidDerivers* = 33
wopOptimiseStore* = 34
wopVerifyStore* = 35
wopBuildDerivation* = 36
wopAddSignatures* = 37
wopNarFromPath* = 38
wopAddToStoreNar* = 39
wopQueryMissing* = 40
wopQueryDerivationOutputMap* = 41
wopRegisterDrvOutput* = 42
wopQueryRealisation* = 43
wopAddMultipleToStore* = 44
wopAddBuildLog* = 45
wopBuildPathsWithResults* = 46
type WorkerOperation* = enum
wopIsValidPath = 1,
wopHasSubstitutes = 3,
wopQueryPathHash = 4, # obsolete
wopQueryReferences = 5, # obsolete
wopQueryReferrers = 6,
wopAddToStore = 7,
wopAddTextToStore = 8, # obsolete since 1.25, Nix 3.0. Use wopAddToStore
wopBuildPaths = 9,
wopEnsurePath = 10,
wopAddTempRoot = 11,
wopAddIndirectRoot = 12,
wopSyncWithGC = 13,
wopFindRoots = 14,
wopExportPath = 16, # obsolete
wopQueryDeriver = 18, # obsolete
wopSetOptions = 19,
wopCollectGarbage = 20,
wopQuerySubstitutablePathInfo = 21,
wopQueryDerivationOutputs = 22, # obsolete
wopQueryAllValidPaths = 23,
wopQueryFailedPaths = 24,
wopClearFailedPaths = 25,
wopQueryPathInfo = 26,
wopImportPaths = 27, # obsolete
wopQueryDerivationOutputNames = 28, # obsolete
wopQueryPathFromHashPart = 29,
wopQuerySubstitutablePathInfos = 30,
wopQueryValidPaths = 31,
wopQuerySubstitutablePaths = 32,
wopQueryValidDerivers = 33,
wopOptimiseStore = 34,
wopVerifyStore = 35,
wopBuildDerivation = 36,
wopAddSignatures = 37,
wopNarFromPath = 38,
wopAddToStoreNar = 39,
wopQueryMissing = 40,
wopQueryDerivationOutputMap = 41,
wopRegisterDrvOutput = 42,
wopQueryRealisation = 43,
wopAddMultipleToStore = 44,
wopAddBuildLog = 45,
wopBuildPathsWithResults = 46,
type
ProtocolError* = object of IOError