From 33e8b0f975cd8934405c568cfa1d7e2a1edfa425 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 20 Aug 2020 03:28:35 +0100 Subject: chore(tvix): Thread a std::ostream through Store::buildPaths This part of the store API needs to carry a handle to the log sink from now on, so that it can be passed in as appropriate from the gRPC handlers. In all places where there is no such handler available at the moment, the discarding log sink has been inserted. This can be used as a convenient grep target in the future. Change-Id: I26628e30b4c6437dccdf8f722ca2e8ed827dfc19 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1797 Tested-by: BuildkiteCI Reviewed-by: kanepyork Reviewed-by: glittershark --- third_party/nix/src/libstore/rpc-store.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'third_party/nix/src/libstore/rpc-store.cc') diff --git a/third_party/nix/src/libstore/rpc-store.cc b/third_party/nix/src/libstore/rpc-store.cc index f3fc5582f3ef..92ad4e762bf9 100644 --- a/third_party/nix/src/libstore/rpc-store.cc +++ b/third_party/nix/src/libstore/rpc-store.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -318,7 +319,8 @@ Path RpcStore::addTextToStore(const std::string& name, return result.path(); } -absl::Status RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) { +absl::Status RpcStore::buildPaths(std::ostream& log_sink, const PathSet& paths, + BuildMode build_mode) { ClientContext ctx; proto::BuildPathsRequest request; for (const auto& path : paths) { @@ -326,14 +328,7 @@ absl::Status RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) { } google::protobuf::Empty response; - request.set_mode(nix::BuildModeToProto(buildMode)); - - // TODO(tazjin): Temporary no-op sink used to discard build output, - // but satisfy the compiler. A real one is needed. - // - // Maybe this should just be stderr, considering that this is the - // *client*, but I'm not sure. - std::ostream discard_logs = DiscardLogsSink(); + request.set_mode(nix::BuildModeToProto(build_mode)); std::unique_ptr> reader = stub_->BuildPaths(&ctx, request); @@ -342,11 +337,11 @@ absl::Status RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) { while (reader->Read(&event)) { if (event.has_build_log()) { // TODO(tazjin): Include .path()? - discard_logs << event.build_log().line(); + log_sink << event.build_log().line(); } else { - discard_logs << std::endl - << "Building path: " << event.building_path().path() - << std::endl; + log_sink << std::endl + << "Building path: " << event.building_path().path() + << std::endl; } // has_result() is not in use in this call (for now) -- cgit 1.4.1