diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-07-14 18:56:30 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-07-14 18:56:30 +0200 |
| commit | dd6c4c39440982e2943906f2fa30dbbb8260540b (patch) | |
| tree | 19e6e1732c4b2cb368d9f1a61e65472a6878143d /service_telemetry.js | |
| parent | 40afdde86f8b9369c2f3e1ef73176c347ccef5f6 (diff) | |
| download | bridge-dd6c4c39440982e2943906f2fa30dbbb8260540b.tar.gz bridge-dd6c4c39440982e2943906f2fa30dbbb8260540b.zip | |
2.14.0 rewrite: modularization
Diffstat (limited to 'service_telemetry.js')
| -rw-r--r-- | service_telemetry.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/service_telemetry.js b/service_telemetry.js new file mode 100644 index 0000000..285de4e --- /dev/null +++ b/service_telemetry.js @@ -0,0 +1,43 @@ +#!/usr/bin/env node +/* jshint esnext: true */ +"use strict"; + +const Promise = require("bluebird"), + Service = require("./service_skeleton.js"); + +const logger = global.logger, + SAMPLE_QUEUE = process.env.SAMPLE_QUEUE || "sample", + SAMPLE_TOURNAMENT_QUEUE = process.env.SAMPLE_TOURNAMENT_QUEUE || "sample_tournament"; + +module.exports = class Analyzer extends Service { + constructor() { + super(); + + this.setTargets({ + "regular": SAMPLE_QUEUE, + "tournament": SAMPLE_TOURNAMENT_QUEUE + }); + + this.setRoutes({ + "/api/match/:match/telemetry/:category?": async (req, res) => { + logger.info("requesting download for Telemetry", { api_id: req.params.match }); + const category = req.params.category || "regular", + db = this.getDatabase(category), + asset = await db.Asset.findOne({ where: { + match_api_id: req.params.match + } }); + if (asset == undefined) { + logger.error("could not find any assets for match", + { api_id: req.params.match }); + res.sendStatus(404); + return; + } + await this.forward(this.getTarget(category), asset.url, { + persistent: true, + headers: { match_api_id: req.params.match } + }); + res.sendStatus(204); + } + }); + } +} |
