UNPKG

zamza

Version:

Apache Kafka discovery, indexing, searches, storage, hooks and HTTP gateway

40 lines (39 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Debug = require("debug"); const debug = Debug("zamza:hookclient"); const request = require("request"); const Bluebird = require("bluebird"); class HookClient { constructor(zamza) { this.calledLately = 0; this.zamza = zamza; this.intv = setInterval(() => { if (this.calledLately > 0) { debug("Called", this.calledLately, "hooks lately"); this.calledLately = 0; } }, 45000); } call(options) { return new Bluebird((resolve, reject) => { request(options, (error, response, body) => { if (error) { return reject(error); } resolve({ status: response.statusCode, headers: response.headers, body, }); }); }); } async close() { debug("Closing.."); if (this.intv) { clearInterval(this.intv); } } } exports.default = HookClient;