about summary refs log tree commit diff
path: root/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-20T01·32+0100
committertazjin <mail@tazj.in>2020-08-20T11·48+0000
commit19e874a9854c0d7f49d79fa98177a84b6997ce9a (patch)
treef6e68f233b45c6e596ee0719d09abf651e7d083f /third_party/nix/src/nix-daemon/nix-daemon-proto.cc
parent883de9b8d71b9cb984d8ff315b4dcc30e0ca9082 (diff)
feat(tvix): Introduce build event streams in worker protocol r/1685
Introduces a new `BuildEvent` proto type which is streamed in response
to calls that trigger builds of derivations.

This type can currently supply build statuses, log lines and
information about builds starting.

This is in preparation for threading build logs through the processes.

Since we have nowhere to send the logs (yet), a null sink is used
instead.

Co-authored-by: Griffin Smith <grfn@gws.fyi>
Change-Id: If7332337b89506c7e404cd20174acdaa1a3be4e8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1793
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/nix-daemon/nix-daemon-proto.cc')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
index ec8e0ff42c..b7d5836091 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -29,7 +29,6 @@ namespace nix::daemon {
 
 using ::google::protobuf::util::TimeUtil;
 using ::grpc::Status;
-using ::nix::proto::BuildStatus;
 using ::nix::proto::PathInfo;
 using ::nix::proto::StorePath;
 using ::nix::proto::StorePaths;
@@ -271,9 +270,9 @@ class WorkerServiceImpl final : public WorkerService::Service {
         __FUNCTION__);
   }
 
-  Status BuildPaths(grpc::ServerContext*,
-                    const nix::proto::BuildPathsRequest* request,
-                    google::protobuf::Empty*) override {
+  Status BuildPaths(
+      grpc::ServerContext*, const nix::proto::BuildPathsRequest* request,
+      grpc::ServerWriter<nix::proto::BuildEvent>* /* writer */) override {
     return HandleExceptions(
         [&]() -> Status {
           PathSet drvs;
@@ -612,7 +611,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
   Status BuildDerivation(
       grpc::ServerContext* context,
       const nix::proto::BuildDerivationRequest* request,
-      nix::proto::BuildDerivationResponse* response) override {
+      grpc::ServerWriter<nix::proto::BuildEvent>* writer) override {
     return HandleExceptions(
         [&]() -> Status {
           auto drv_path = request->drv_path().path();
@@ -625,11 +624,19 @@ class WorkerServiceImpl final : public WorkerService::Service {
             return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
           }
 
-          auto res = store_->buildDerivation(drv_path, drv, *build_mode);
+          BuildResult res = store_->buildDerivation(drv_path, drv, *build_mode);
+
+          proto::BuildResult proto_res{};
+          proto_res.set_status(res.status_to_proto());
+
+          if (!res.errorMsg.empty()) {
+            proto_res.set_msg(res.errorMsg);
+          }
 
-          response->set_status(res.status_to_proto());
-          response->set_error_message(res.errorMsg);
+          proto::BuildEvent event{};
+          *event.mutable_result() = proto_res;
 
+          writer->Write(event);
           return Status::OK;
         },
         __FUNCTION__);