fix(tvix): Wrap remaining RPCs in HandleExceptions

Wrap the BuildPaths and AddTextToStore RPC handlers in HandleExceptions.
These were missed in the original pass due to a merge.

Change-Id: Ie5be45e6098fba7a2b6b1c1be81578cb742c2880
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1689
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
Griffin Smith 2020-08-08 14:30:55 -04:00 committed by glittershark
parent 3115113854
commit 053a138002

View file

@ -256,35 +256,43 @@ class WorkerServiceImpl final : public WorkerService::Service {
Status AddTextToStore(grpc::ServerContext*, Status AddTextToStore(grpc::ServerContext*,
const nix::proto::AddTextToStoreRequest* request, const nix::proto::AddTextToStoreRequest* request,
nix::proto::StorePath* response) override { nix::proto::StorePath* response) override {
PathSet references; return HandleExceptions(
for (const auto& ref : request->references()) { [&]() -> Status {
references.insert(ref); PathSet references;
} for (const auto& ref : request->references()) {
auto path = references.insert(ref);
store_->addTextToStore(request->name(), request->content(), references); }
response->set_path(path); auto path = store_->addTextToStore(request->name(),
return Status::OK; request->content(), references);
response->set_path(path);
return Status::OK;
},
__FUNCTION__);
} }
Status BuildPaths(grpc::ServerContext*, Status BuildPaths(grpc::ServerContext*,
const nix::proto::BuildPathsRequest* request, const nix::proto::BuildPathsRequest* request,
google::protobuf::Empty*) override { google::protobuf::Empty*) override {
PathSet drvs; return HandleExceptions(
for (const auto& drv : request->drvs()) { [&]() -> Status {
drvs.insert(drv); PathSet drvs;
} for (const auto& drv : request->drvs()) {
auto mode = BuildModeFrom(request->mode()); drvs.insert(drv);
}
auto mode = BuildModeFrom(request->mode());
if (!mode.has_value()) { if (!mode.has_value()) {
return Status(grpc::StatusCode::INTERNAL, "Invalid build mode"); return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
} }
// TODO(grfn): If mode is repair and not trusted, we need to return an error // TODO(grfn): If mode is repair and not trusted, we need to return an
// here (but we can't yet because we don't know anything about trusted // error here (but we can't yet because we don't know anything about
// users) // trusted users)
store_->buildPaths(drvs, mode.value()); store_->buildPaths(drvs, mode.value());
return Status::OK; return Status::OK;
},
__FUNCTION__);
} }
Status AddTempRoot(grpc::ServerContext*, const nix::proto::StorePath* request, Status AddTempRoot(grpc::ServerContext*, const nix::proto::StorePath* request,