about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-07-16T23·12-0400
committerglittershark <grfn@gws.fyi>2020-07-16T23·25+0000
commitec859afe9577cafa074cd15a0cfb41ae51c419b5 (patch)
treed92303c5cc88bd2780079cb25a1566717b98cd95 /third_party/nix/src
parent5c9af8faee5c061a0d75f6f0773dd2ddcdb36adc (diff)
feat(3p/nix/nix-daemon): Implement Worker::QueryMissing handler r/1341
Change-Id: I004a0c7969e1fe27b844adfed2d3ba3e6c5279bb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1227
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc30
1 files changed, 30 insertions, 0 deletions
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 511058c3e25d..85adb98e9abb 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -76,6 +76,36 @@ class WorkerServiceImpl final : public Worker::Service {
     return Status::OK;
   }
 
+  Status QueryMissing(grpc::ServerContext* context, const StorePaths* request,
+                      nix::proto::QueryMissingResponse* response) override {
+    std::set<Path> targets;
+    for (auto& path : request->paths()) {
+      targets.insert(path);
+    }
+    PathSet will_build;
+    PathSet will_substitute;
+    PathSet unknown;
+    // TODO(grfn): Switch to concrete size type
+    unsigned long long download_size;
+    unsigned long long nar_size;
+
+    store_->queryMissing(targets, will_build, will_substitute, unknown,
+                         download_size, nar_size);
+    for (auto& path : will_build) {
+      response->add_will_build(path);
+    }
+    for (auto& path : will_substitute) {
+      response->add_will_substitute(path);
+    }
+    for (auto& path : unknown) {
+      response->add_unknown(path);
+    }
+    response->set_download_size(download_size);
+    response->set_nar_size(nar_size);
+
+    return Status::OK;
+  };
+
  private:
   // TODO(tazjin): Who owns the store?
   nix::Store* store_;