libstore: asyncify Store::queryMissing
Change-Id: I33cc483a3a60208dc2a2c99fa277738be356f5f2
This commit is contained in:
@@ -314,8 +314,8 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
|
||||
fetch binary cache data. */
|
||||
uint64_t downloadSize, narSize;
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
store->queryMissing(paths,
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
aio.blockOn(store->queryMissing(paths,
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize));
|
||||
|
||||
if (settings.printMissing) {
|
||||
aio.blockOn(printMissing(
|
||||
|
||||
@@ -142,9 +142,9 @@ static void opRealise(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
uint64_t downloadSize, narSize;
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
store->queryMissing(
|
||||
aio.blockOn(store->queryMissing(
|
||||
toDerivedPaths(paths),
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize));
|
||||
|
||||
/* Filter out unknown paths from `paths`. */
|
||||
if (ignoreUnknown) {
|
||||
|
||||
@@ -52,7 +52,7 @@ printMissing(ref<Store> store, const std::vector<DerivedPath> & paths, Verbosity
|
||||
try {
|
||||
uint64_t downloadSize, narSize;
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
store->queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
TRY_AWAIT(store->queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize, narSize));
|
||||
TRY_AWAIT(printMissing(store, willBuild, willSubstitute, unknown, downloadSize, narSize, lvl));
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
|
||||
@@ -1240,10 +1240,10 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
|
||||
void addSignatures(const StorePath & storePath, const StringSet & sigs) override
|
||||
{ unsupported("addSignatures"); }
|
||||
|
||||
void queryMissing(const std::vector<DerivedPath> & targets,
|
||||
kj::Promise<Result<void>> queryMissing(const std::vector<DerivedPath> & targets,
|
||||
StorePathSet & willBuild, StorePathSet & willSubstitute, StorePathSet & unknown,
|
||||
uint64_t & downloadSize, uint64_t & narSize) override
|
||||
{
|
||||
try {
|
||||
/* This is slightly impure since it leaks information to the
|
||||
client about what paths will be built/substituted or are
|
||||
already present. Probably not a big deal. */
|
||||
@@ -1256,8 +1256,11 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
|
||||
unknown.insert(pathPartOfReq(req));
|
||||
}
|
||||
|
||||
next->queryMissing(allowed, willBuild, willSubstitute,
|
||||
unknown, downloadSize, narSize);
|
||||
TRY_AWAIT(next->queryMissing(allowed, willBuild, willSubstitute,
|
||||
unknown, downloadSize, narSize));
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
virtual kj::Promise<Result<std::optional<std::string>>> getBuildLogExact(const StorePath & path) override
|
||||
|
||||
@@ -940,7 +940,9 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
logger->startWork();
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
uint64_t downloadSize, narSize;
|
||||
store->queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
aio.blockOn(
|
||||
store->queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize, narSize)
|
||||
);
|
||||
logger->stopWork();
|
||||
to << WorkerProto::write(*store, wconn, willBuild);
|
||||
to << WorkerProto::write(*store, wconn, willSubstitute);
|
||||
|
||||
+17
-8
@@ -142,7 +142,7 @@ struct QueryMissingContext
|
||||
|
||||
KJ_DISALLOW_COPY_AND_MOVE(QueryMissingContext);
|
||||
|
||||
void queryMissing(const std::vector<DerivedPath> & targets);
|
||||
kj::Promise<Result<void>> queryMissing(const std::vector<DerivedPath> & targets);
|
||||
|
||||
void enqueueDerivedPaths(ref<SingleDerivedPath> inputDrv, const DerivedPathMap<StringSet>::ChildNode & inputNode)
|
||||
{
|
||||
@@ -336,25 +336,34 @@ struct QueryMissingContext
|
||||
};
|
||||
}
|
||||
|
||||
void QueryMissingContext::queryMissing(const std::vector<DerivedPath> & targets)
|
||||
{
|
||||
kj::Promise<Result<void>> QueryMissingContext::queryMissing(const std::vector<DerivedPath> & targets)
|
||||
try {
|
||||
for (auto & path : targets) {
|
||||
pool.enqueueWithAio([=, this](AsyncIoRoot & aio) { doPath(aio, path); });
|
||||
}
|
||||
|
||||
pool.process();
|
||||
TRY_AWAIT(pool.processAsync());
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
void Store::queryMissing(const std::vector<DerivedPath> & targets,
|
||||
|
||||
kj::Promise<Result<void>> Store::queryMissing(const std::vector<DerivedPath> & targets,
|
||||
StorePathSet & willBuild_, StorePathSet & willSubstitute_, StorePathSet & unknown_,
|
||||
uint64_t & downloadSize_, uint64_t & narSize_)
|
||||
{
|
||||
try {
|
||||
Activity act(*logger, lvlDebug, actUnknown, "querying info about missing paths");
|
||||
|
||||
downloadSize_ = narSize_ = 0;
|
||||
|
||||
QueryMissingContext{*this, willBuild_, willSubstitute_, unknown_, downloadSize_, narSize_}
|
||||
.queryMissing(targets);
|
||||
TRY_AWAIT(
|
||||
QueryMissingContext{*this, willBuild_, willSubstitute_, unknown_, downloadSize_, narSize_}
|
||||
.queryMissing(targets)
|
||||
);
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -895,10 +895,10 @@ void RemoteStore::addSignatures(const StorePath & storePath, const StringSet & s
|
||||
}
|
||||
|
||||
|
||||
void RemoteStore::queryMissing(const std::vector<DerivedPath> & targets,
|
||||
kj::Promise<Result<void>> RemoteStore::queryMissing(const std::vector<DerivedPath> & targets,
|
||||
StorePathSet & willBuild, StorePathSet & willSubstitute, StorePathSet & unknown,
|
||||
uint64_t & downloadSize, uint64_t & narSize)
|
||||
{
|
||||
try {
|
||||
auto conn(getConnection());
|
||||
conn->to << WorkerProto::Op::QueryMissing;
|
||||
conn->to << WorkerProto::write(*this, *conn, targets);
|
||||
@@ -907,6 +907,9 @@ void RemoteStore::queryMissing(const std::vector<DerivedPath> & targets,
|
||||
willSubstitute = WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||
unknown = WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||
conn->from >> downloadSize >> narSize;
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
|
||||
void addSignatures(const StorePath & storePath, const StringSet & sigs) override;
|
||||
|
||||
void queryMissing(const std::vector<DerivedPath> & targets,
|
||||
kj::Promise<Result<void>> queryMissing(const std::vector<DerivedPath> & targets,
|
||||
StorePathSet & willBuild, StorePathSet & willSubstitute, StorePathSet & unknown,
|
||||
uint64_t & downloadSize, uint64_t & narSize) override;
|
||||
|
||||
|
||||
@@ -783,8 +783,8 @@ try {
|
||||
paths2.emplace_back(DerivedPath::Opaque{path});
|
||||
uint64_t downloadSize, narSize;
|
||||
StorePathSet willBuild, willSubstitute, unknown;
|
||||
queryMissing(paths2,
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||
TRY_AWAIT(queryMissing(paths2,
|
||||
willBuild, willSubstitute, unknown, downloadSize, narSize));
|
||||
|
||||
if (!willSubstitute.empty())
|
||||
try {
|
||||
|
||||
@@ -790,7 +790,7 @@ public:
|
||||
* derivations that will be built, and the set of output paths that
|
||||
* will be substituted.
|
||||
*/
|
||||
virtual void queryMissing(const std::vector<DerivedPath> & targets,
|
||||
virtual kj::Promise<Result<void>> queryMissing(const std::vector<DerivedPath> & targets,
|
||||
StorePathSet & willBuild, StorePathSet & willSubstitute, StorePathSet & unknown,
|
||||
uint64_t & downloadSize, uint64_t & narSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user