From 19e874a9854c0d7f49d79fa98177a84b6997ce9a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 20 Aug 2020 02:32:51 +0100 Subject: feat(tvix): Introduce build event streams in worker protocol 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 Change-Id: If7332337b89506c7e404cd20174acdaa1a3be4e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1793 Tested-by: BuildkiteCI Reviewed-by: glittershark Reviewed-by: kanepyork --- third_party/nix/src/nix-daemon/nix-daemon-proto.cc | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'third_party/nix/src/nix-daemon') 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 ec8e0ff42cc3..b7d5836091af 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* /* 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* 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__); -- cgit 1.4.1