diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-10 22:23:45 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-10 22:23:45 +0200 |
| commit | 08d8d9ff20ef5f38066d14dba9a36659a568caed (patch) | |
| tree | cd47834fe80d0e5204a02d339282516d7d428041 | |
| parent | 30667f2ae2df7491eaf4c2f4776296c617f6602c (diff) | |
| download | apigrabber-08d8d9ff20ef5f38066d14dba9a36659a568caed.tar.gz apigrabber-08d8d9ff20ef5f38066d14dba9a36659a568caed.zip | |
split API queue and sample queue
| -rw-r--r-- | worker.js | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -20,6 +20,7 @@ if (MADGLORY_TOKEN == undefined) throw "Need an API token"; rabbit = await amqp.connect(RABBITMQ_URI); ch = await rabbit.createChannel(); await ch.assertQueue("grab", {durable: true}); + await ch.assertQueue("grab_sample", {durable: true}); await ch.assertQueue("process", {durable: true}); break; } catch (err) { @@ -35,6 +36,13 @@ if (MADGLORY_TOKEN == undefined) throw "Need an API token"; await getAPI(payload, "matches"); if (msg.properties.type == "samples") await getAPI(payload, "samples"); + + console.log("done"); + ch.ack(msg); + }, { noAck: false }); + + ch.consume("grab_sample", async (msg) => { + let payload = JSON.parse(msg.content.toString()); if (msg.properties.type == "sample") await getSample(payload); @@ -74,7 +82,7 @@ if (MADGLORY_TOKEN == undefined) throw "Need an API token"; if (where == "samples") { // send to self await Promise.all(datas - .map((sample) => ch.sendToQueue("grab", + .map((sample) => ch.sendToQueue("grab_sample", new Buffer(JSON.stringify(sample.attributes.URL)), { persistent: true, type: "sample" }) )); |
