diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-08-17 20:47:27 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-08-17 20:47:27 +0200 |
| commit | c0e5a0ace481f4b444ad490b7519fe3a6972b9e8 (patch) | |
| tree | 8ecb4cbeea8749a6570f476352bad90e69b2f342 | |
| parent | aa6bba87ed35b839921532420efbdc816e289486 (diff) | |
| download | bridge-c0e5a0ace481f4b444ad490b7519fe3a6972b9e8.tar.gz bridge-c0e5a0ace481f4b444ad490b7519fe3a6972b9e8.zip | |
fix wrong queue defaults, fix pipe outs not being mapped
| -rw-r--r-- | service_grab.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/service_grab.js b/service_grab.js index 6402919..9b9c99f 100644 --- a/service_grab.js +++ b/service_grab.js @@ -10,8 +10,8 @@ const api = require("../orm/api"), const GRABSTART = process.env.GRABSTART || "2017-02-14T00:00:00Z", BRAWL_GRABSTART = process.env.BRAWL_GRABSTART || "2017-02-14T00:00:00Z", // pipe inputs (special to service_grab, see below) - PLAYER_PROCESS_QUEUE = process.env.PLAYER_PROCESS_QUEUE || "process", - PLAYER_BRAWL_PROCESS_QUEUE = process.env.PLAYER_BRAWL_PROCESS_QUEUE || "process_brawl", + PLAYER_PROCESS_QUEUE = process.env.PLAYER_PROCESS_QUEUE || "process_player", + PLAYER_BRAWL_PROCESS_QUEUE = process.env.PLAYER_BRAWL_PROCESS_QUEUE || "process_brawl_player", PLAYER_TOURNAMENT_PROCESS_QUEUE = process.env.PLAYER_TOURNAMENT_PROCESS_QUEUE || "process_tournament", GRAB_QUEUE = process.env.GRAB_QUEUE || "grab", GRAB_BRAWL_QUEUE = process.env.GRAB_BRAWL_QUEUE || "grab_brawl", @@ -35,6 +35,7 @@ module.exports = class Analyzer extends Service { constructor() { super(); + // TODO not all queues are being created this.setTargets({ "regular": GRAB_QUEUE, "brawl": GRAB_BRAWL_QUEUE, @@ -46,20 +47,20 @@ module.exports = class Analyzer extends Service { // category=[pipe in] spreads to multiple categories=[pipe out] // Map { pipe in: [pipe out 1, pipe out 2, …] } - this.categoryPipe = new Map({ + this.categoryPipe = new Map(Object.entries({ "regular": PIPE_REGULAR_OUT, "brawl": PIPE_BRAWL_OUT, "tournament": PIPE_TOURNAMENT_OUT, "regular_player": PIPE_REGULAR_PLAYER_OUT, "brawl_player": PIPE_BRAWL_PLAYER_OUT, "tournament_player": PIPE_TOURNAMENT_PLAYER_OUT - }); + })); // wrapper around getTarget to support pipes - this.getTargets((pipeIn) => + this.getTargets = (pipeIn) => this.categoryPipe.get(pipeIn) .map((pipeOut) => - this.getTarget(pipeOut))); + this.getTarget(pipeOut)); // setup API endpoints this.setRoutes({ @@ -196,7 +197,7 @@ module.exports = class Analyzer extends Service { await Promise.each(this.getSplitGrabs(payload_template, start, end), async (payload) => { logger.info("requesting update", { name: name, region: region }); - await Promise.all(this.getTargets(category), async (target) => { + await Promise.map(this.getTargets(category), async (target) => { await this.forward(target, JSON.stringify(payload), { persistent: true, headers: { notify: "player." + name } @@ -221,7 +222,7 @@ module.exports = class Analyzer extends Service { }); await Promise.each(this.getSplitGrabs(payload_template, grabstart, now), async (payload) => { - await Promise.all(this.getTargets(category), async (target) => { + await Promise.map(this.getTargets(category), async (target) => { await this.forward(target, JSON.stringify(payload), { persistent: true, headers: { notify: "player." + names } @@ -268,7 +269,7 @@ module.exports = class Analyzer extends Service { await this.notify("player." + name, "search_success"); // send to processor, so the player is in db // no matter whether we find matches or not - await Promise.all(this.getTargets(category + "_player"), async (target) => { + await Promise.map(this.getTargets(category + "_player"), async (target) => { await this.forward(target, JSON.stringify(player), { persistent: true, type: "player", headers: { notify: "player." + player.name } |
