Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gatewayd queues javascript api spec
var gatewayd = require('gatewayd');
// process records in the postgres queue table one at a time forever, composed of records in:
// select * from external_transactions where status='queued' and deposit='false' limit 1;
gatewayd.queues.withdrawals.work(job);
function job(withdrawal, next) {
// do something with the withdrawal, like sending to Dogecoind
dogecoinClient.sendWithdrawal(withdrawal)
.then(function() {
// update the withdrawal status to remove from the queue
withdrawal.udpateAttributes({ status: 'cleared' })
.complete(next);
});
}
// ******** TESTS *******
assert.strictEqual(gatewayd.queues.withdrawals.modelName, 'externalTransactions');
assert.strictEqual(gatewayd.queues.withdrawals.predicate, { status: queued, deposit: false });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment