aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/serve-protocol.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 04:59:31 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 04:59:31 +0100
commit7f590ea7096d1e1bbbe73697358fef962d0fb494 (patch)
tree379ef50da30c3ff0b49df6ac1c28d3cfac7e0f69 /src/libstore/serve-protocol.cc
parent4d9dde15efbc05af471acb3efc5b04c087ceeef0 (diff)
Merge pull request #6223 from obsidiansystems/worker-proto-with-version
Give `nix daemon` and `nix-store --serve` protocols separate serializers with version info (cherry picked from commit 8b68bbb77745fda0d14939b6c23d31cc89da41ce) Change-Id: Ia3d3b9fbaf9f0ae62ab225020b7d14790e793655
Diffstat (limited to 'src/libstore/serve-protocol.cc')
-rw-r--r--src/libstore/serve-protocol.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libstore/serve-protocol.cc b/src/libstore/serve-protocol.cc
index 16a62b5bc..97a0ddf0e 100644
--- a/src/libstore/serve-protocol.cc
+++ b/src/libstore/serve-protocol.cc
@@ -2,6 +2,7 @@
#include "util.hh"
#include "path-with-outputs.hh"
#include "store-api.hh"
+#include "build-result.hh"
#include "serve-protocol.hh"
#include "serve-protocol-impl.hh"
#include "archive.hh"
@@ -12,4 +13,46 @@ namespace nix {
/* protocol-specific definitions */
+BuildResult ServeProto::Serialise<BuildResult>::read(const Store & store, ServeProto::ReadConn conn)
+{
+ BuildResult status;
+ status.status = (BuildResult::Status) readInt(conn.from);
+ conn.from >> status.errorMsg;
+
+ if (GET_PROTOCOL_MINOR(conn.version) >= 3)
+ conn.from
+ >> status.timesBuilt
+ >> status.isNonDeterministic
+ >> status.startTime
+ >> status.stopTime;
+ if (GET_PROTOCOL_MINOR(conn.version) >= 6) {
+ auto builtOutputs = ServeProto::Serialise<DrvOutputs>::read(store, conn);
+ for (auto && [output, realisation] : builtOutputs)
+ status.builtOutputs.insert_or_assign(
+ std::move(output.outputName),
+ std::move(realisation));
+ }
+ return status;
+}
+
+void ServeProto::Serialise<BuildResult>::write(const Store & store, ServeProto::WriteConn conn, const BuildResult & status)
+{
+ conn.to
+ << status.status
+ << status.errorMsg;
+
+ if (GET_PROTOCOL_MINOR(conn.version) >= 3)
+ conn.to
+ << status.timesBuilt
+ << status.isNonDeterministic
+ << status.startTime
+ << status.stopTime;
+ if (GET_PROTOCOL_MINOR(conn.version) >= 6) {
+ DrvOutputs builtOutputs;
+ for (auto & [output, realisation] : status.builtOutputs)
+ builtOutputs.insert_or_assign(realisation.id, realisation);
+ ServeProto::write(store, conn, builtOutputs);
+ }
+}
+
}