MCPcopy Create free account
hub / github.com/3rdparty/libprocess / _snapshot

Method _snapshot

src/metrics/metrics.cpp:191–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190
191Future<http::Response> MetricsProcess::_snapshot(
192 const http::Request& request,
193 const Option<http::authentication::Principal>&)
194{
195 // Parse the 'timeout' parameter.
196 Option<Duration> timeout;
197
198 if (request.url.query.contains("timeout")) {
199 string parameter = request.url.query.get("timeout").get();
200
201 Try<Duration> duration = Duration::parse(parameter);
202
203 if (duration.isError()) {
204 return http::BadRequest(
205 "Invalid timeout '" + parameter + "': " + duration.error() + ".\n");
206 }
207
208 timeout = duration.get();
209 }
210
211 Future<Nothing> acquire = Nothing();
212
213 if (limiter.isSome()) {
214 acquire = limiter.get()->acquire();
215 }
216
217 return acquire.then(defer(self(), &Self::snapshot, timeout))
218 .then([request](const map<string, double>& metrics)
219 -> http::Response {
220 return http::OK(jsonify(metrics), request.url.query.get("jsonp"));
221 });
222}
223
224
225Future<map<string, double>> MetricsProcess::__snapshot(

Callers

nothing calls this directly

Calls 7

BadRequestClass · 0.85
deferFunction · 0.85
OKClass · 0.85
parseFunction · 0.50
getMethod · 0.45
acquireMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected