feat(3p/nix/nix-daemon): Implement Worker::HasSubstitutes handler

Change-Id: I0b01b554eee4b4e31416aabb498ea3d8b8a8092b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1226
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2020-07-16 23:40:53 +01:00 committed by tazjin
parent bb66262068
commit 32735eebdd

View file

@ -21,6 +21,16 @@ class WorkerServiceImpl final : public Worker::Service {
return Status::OK;
}
Status HasSubstitutes(grpc::ServerContext* context, const StorePath* request,
nix::proto::HasSubstitutesResponse* response) {
const auto& path = request->path();
store_->assertStorePath(path);
PathSet res = store_->querySubstitutablePaths({path});
response->set_has_substitutes(res.find(path) != res.end());
return Status::OK;
}
private:
// TODO(tazjin): Who owns the store?
nix::Store* store_;