Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
serve-protocol.hh
Go to the documentation of this file.
1#pragma once
3
4#include "common-protocol.hh"
5
6namespace nix {
7
8#define SERVE_MAGIC_1 0x390c9deb
9#define SERVE_MAGIC_2 0x5452eecb
10
11#define SERVE_PROTOCOL_VERSION (2 << 8 | 7)
12#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
13#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
14
15
16struct StoreDirConfig;
17struct Source;
18
19// items being serialised
20struct BuildResult;
22
23
31{
35 enum struct Command : uint64_t;
36
42 using Version = unsigned int;
43
48 struct ReadConn {
49 Source & from;
50 Version version;
51 };
52
57 struct WriteConn {
58 Sink & to;
59 Version version;
60 };
61
69
76 template<typename T>
77 struct Serialise;
78 // This is the definition of `Serialise` we *want* to put here, but
79 // do not do so.
80 //
81 // See `worker-protocol.hh` for a longer explanation.
82#if 0
83 {
84 static T read(const StoreDirConfig & store, ReadConn conn);
85 static void write(const StoreDirConfig & store, WriteConn conn, const T & t);
86 };
87#endif
88
93 template<typename T>
94 static void write(const StoreDirConfig & store, WriteConn conn, const T & t)
95 {
96 ServeProto::Serialise<T>::write(store, conn, t);
97 }
98
104 struct BuildOptions;
105};
106
107enum struct ServeProto::Command : uint64_t
108{
109 QueryValidPaths = 1,
110 QueryPathInfos = 2,
111 DumpStorePath = 3,
112 ImportPaths = 4,
113 ExportPaths = 5,
114 BuildPaths = 6,
115 QueryClosure = 7,
116 BuildDerivation = 8,
117 AddToStoreNar = 9,
118};
119
120
126 time_t maxSilentTime = -1;
127 time_t buildTimeout = -1;
128 size_t maxLogSize = -1;
129 size_t nrRepeats = -1;
130 bool enforceDeterminism = -1;
131 bool keepFailed = -1;
132
133 bool operator == (const ServeProto::BuildOptions &) const = default;
134};
135
142inline Sink & operator << (Sink & sink, ServeProto::Command op)
143{
144 return sink << (uint64_t) op;
145}
146
152inline std::ostream & operator << (std::ostream & s, ServeProto::Command op)
153{
154 return s << (uint64_t) op;
155}
156
167#define DECLARE_SERVE_SERIALISER(T) \
168 struct ServeProto::Serialise< T > \
169 { \
170 static T read(const StoreDirConfig & store, ServeProto::ReadConn conn); \
171 static void write(const StoreDirConfig & store, ServeProto::WriteConn conn, const T & t); \
172 };
173
174template<>
176template<>
178template<>
180
181template<typename T>
183template<typename T>
185template<typename... Ts>
186DECLARE_SERVE_SERIALISER(std::tuple<Ts...>);
187
188#define COMMA_ ,
189template<typename K, typename V>
190DECLARE_SERVE_SERIALISER(std::map<K COMMA_ V>);
191#undef COMMA_
192
193}
ChunkedVector< std::string, 8192 > store
Definition lexer.l:1011
return s
Definition lexer.l:459
int
Definition lexer.l:2928
T t
Definition lexer.l:154
#define DECLARE_SERVE_SERIALISER(T)
Definition serve-protocol.hh:167
Definition build-result.hh:14
Definition serve-protocol-connection.hh:10
Definition serve-protocol-connection.hh:90
Definition serve-protocol.hh:121
time_t maxSilentTime
Definition serve-protocol.hh:126
Definition serve-protocol.hh:48
Definition serve-protocol-impl.hh:42
Definition serve-protocol.hh:57
Definition serve-protocol.hh:31
static void write(const StoreDirConfig &store, WriteConn conn, const T &t)
Definition serve-protocol.hh:94
unsigned int Version
Definition serve-protocol.hh:42
Definition serialise.hh:20
Definition serialise.hh:68
Definition store-dir-config.hh:22
Definition path-info.hh:42