From 6d65b7fb9242eb827d5d4036f0fa8816430eb364 Mon Sep 17 00:00:00 2001 From: Heikki Kallasjoki Date: Sun, 23 Dec 2018 00:06:59 +0000 Subject: Move the collector loop into scrape server code. This paves the way for supporting parallel scrapes (#19); the implementation for that is going to need to track the state of the current scrape. --- scrape.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scrape.c') diff --git a/scrape.c b/scrape.c index c86e853..f632e4e 100644 --- a/scrape.c +++ b/scrape.c @@ -110,7 +110,7 @@ scrape_server *scrape_listen(const char *port) { return srv; } -void scrape_serve(scrape_server *srv, scrape_handler *handler, void *handler_ctx) { +void scrape_serve(scrape_server *srv, unsigned ncoll, const struct collector *coll[], void *coll_ctx[]) { struct scrape_req req; req.buf = bbuf_alloc(BUF_INITIAL, BUF_MAX); @@ -137,8 +137,10 @@ void scrape_serve(scrape_server *srv, scrape_handler *handler, void *handler_ctx continue; } - if (handle_http(&req)) - handler(&req, handler_ctx); + if (handle_http(&req)) { + for (unsigned c = 0; c < ncoll; c++) + coll[c]->collect(&req, coll_ctx[c]); + } close(req.socket); } } -- cgit 1.4.1