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 <rikingcoding@gmail.com>
Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2020-08-20 03:28:35 +01:00 committed by tazjin
parent f7fa77f14d
commit 33e8b0f975
15 changed files with 63 additions and 43 deletions

View file

@ -290,7 +290,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
Status BuildPaths(
grpc::ServerContext*, const nix::proto::BuildPathsRequest* request,
grpc::ServerWriter<nix::proto::BuildEvent>* /* writer */) override {
grpc::ServerWriter<nix::proto::BuildEvent>* writer) override {
return HandleExceptions(
[&]() -> Status {
PathSet drvs;
@ -303,11 +303,14 @@ class WorkerServiceImpl final : public WorkerService::Service {
return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
}
BuildLogStreambuf log_buffer(writer);
std::ostream log_sink(&log_buffer);
// TODO(grfn): If mode is repair and not trusted, we need to return an
// error here (but we can't yet because we don't know anything about
// trusted users)
return nix::util::proto::AbslToGRPCStatus(
store_->buildPaths(drvs, mode.value()));
store_->buildPaths(log_sink, drvs, mode.value()));
},
__FUNCTION__);
}