diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-05 20:37:48 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-05 20:37:48 +0000 |
commit | 6c66331d5c34d97092a9b5e2832fed73e0da3c87 (patch) | |
tree | def96b2ea891dfaceb7f297e2aedad519e88e1f8 | |
parent | ed96e603e116123c1e44f5108b67b472b2c96538 (diff) |
WIP: Put the worker protocol `read` and `write` in a namespace to disambig
-rw-r--r-- | src/libstore/remote-store.cc | 6 | ||||
-rw-r--r-- | src/libstore/worker-protocol.hh | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 2c0857466..96e0aabba 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -58,6 +58,8 @@ void writeStorePathCAMap(const Store & store, Sink & out, const StorePathCAMap & } +namespace worker_proto { + StorePath read(const Store & store, Source & from, Phantom<StorePath> _) { return store.parseStorePath(readString(from)); @@ -68,6 +70,8 @@ void write(const Store & store, Sink & out, const StorePath & storePath) out << store.printStorePath(storePath); } +} + /* TODO: Separate these store impls into different files, give them better names */ RemoteStore::RemoteStore(const Params & params) @@ -461,7 +465,7 @@ std::map<std::string, std::optional<StorePath>> RemoteStore::queryDerivationOutp auto conn(getConnection()); conn->to << wopQueryDerivationOutputMap << printStorePath(path); conn.processStderr(); - return read(*this, conn->from, Phantom<std::map<std::string, std::optional<StorePath>>> {}); + return worker_proto::read(*this, conn->from, Phantom<std::map<std::string, std::optional<StorePath>>> {}); } diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 384b81f08..fdd700668 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -74,6 +74,10 @@ void writeStorePaths(const Store & store, Sink & out, const StorePathSet & paths template<typename T> struct Phantom {}; + +namespace worker_proto { +/* FIXME maybe move more stuff inside here */ + template<typename T> std::map<std::string, T> read(const Store & store, Source & from, Phantom<std::map<std::string, T>> _) { @@ -81,7 +85,7 @@ std::map<std::string, T> read(const Store & store, Source & from, Phantom<std::m auto size = (size_t)readInt(from); while (size--) { auto thisKey = readString(from); - resMap.insert_or_assign(std::move(thisKey), read(store, from, Phantom<T> {})); + resMap.insert_or_assign(std::move(thisKey), nix::worker_proto::read(store, from, Phantom<T> {})); } return resMap; } @@ -92,7 +96,7 @@ void write(const Store & store, Sink & out, const std::map<string, T> & resMap) out << resMap.size(); for (auto & i : resMap) { out << i.first; - write(store, out, i.second); + nix::worker_proto::write(store, out, i.second); } } @@ -104,7 +108,7 @@ std::optional<T> read(const Store & store, Source & from, Phantom<std::optional< case 0: return std::nullopt; case 1: - return read(store, from, Phantom<T> {}); + return nix::worker_proto::read(store, from, Phantom<T> {}); default: throw Error("got an invalid tag bit for std::optional: %#04x", tag); } @@ -115,13 +119,16 @@ void write(const Store & store, Sink & out, const std::optional<T> & optVal) { out << (optVal ? 1 : 0); if (optVal) - write(store, out, *optVal); + nix::worker_proto::write(store, out, *optVal); } StorePath read(const Store & store, Source & from, Phantom<StorePath> _); void write(const Store & store, Sink & out, const StorePath & storePath); +} + + StorePathCAMap readStorePathCAMap(const Store & store, Source & from); void writeStorePathCAMap(const Store & store, Sink & out, const StorePathCAMap & paths); |