1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 23:42:43 +01:00

Merge pull request #10782 from obsidiansystems/both-connections

Factor our connection code for worker proto like serve proto
This commit is contained in:
Eelco Dolstra 2024-06-03 15:10:38 +02:00 committed by GitHub
commit d16fcaee21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 906 additions and 452 deletions

View file

@ -77,6 +77,19 @@ struct WorkerProto
Version version;
};
/**
* Stripped down serialization logic suitable for sharing with Hydra.
*
* @todo remove once Hydra uses Store abstraction consistently.
*/
struct BasicClientConnection;
struct BasicServerConnection;
/**
* Extra information provided as part of protocol negotation.
*/
struct ClientHandshakeInfo;
/**
* Data type for canonical pairs of serialisers for the worker protocol.
*
@ -167,6 +180,33 @@ enum struct WorkerProto::Op : uint64_t
AddPermRoot = 47,
};
struct WorkerProto::ClientHandshakeInfo
{
/**
* The version of the Nix daemon that is processing our requests
.
*
* Do note, it may or may not communicating with another daemon,
* rather than being an "end" `LocalStore` or similar.
*/
std::optional<std::string> daemonNixVersion;
/**
* Whether the remote side trusts us or not.
*
* 3 values: "yes", "no", or `std::nullopt` for "unknown".
*
* Note that the "remote side" might not be just the end daemon, but
* also an intermediary forwarder that can make its own trusting
* decisions. This would be the intersection of all their trust
* decisions, since it takes only one link in the chain to start
* denying operations.
*/
std::optional<TrustedFlag> remoteTrustsUs;
bool operator == (const ClientHandshakeInfo &) const = default;
};
/**
* Convenience for sending operation codes.
*
@ -221,6 +261,8 @@ template<>
DECLARE_WORKER_SERIALISER(std::optional<TrustedFlag>);
template<>
DECLARE_WORKER_SERIALISER(std::optional<std::chrono::microseconds>);
template<>
DECLARE_WORKER_SERIALISER(WorkerProto::ClientHandshakeInfo);
template<typename T>
DECLARE_WORKER_SERIALISER(std::vector<T>);