aboutsummaryrefslogtreecommitdiffstats
path: root/packages/testnet-faucets/src/ts/dispatch_queue.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-02-08 03:00:42 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-02-08 03:00:42 +0800
commit9ff4cacf0f9122c035537632d68169d7c2d5763f (patch)
tree6a27330cc3b1b2076e933a573312eaac2948b40b /packages/testnet-faucets/src/ts/dispatch_queue.ts
parentf3c6cce4559d096a2f3babfc7af670d078a6f0dd (diff)
downloaddexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.tar
dexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.tar.gz
dexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.tar.bz2
dexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.tar.lz
dexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.tar.xz
dexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.tar.zst
dexon-sol-tools-9ff4cacf0f9122c035537632d68169d7c2d5763f.zip
Addressed review comments
Diffstat (limited to 'packages/testnet-faucets/src/ts/dispatch_queue.ts')
-rw-r--r--packages/testnet-faucets/src/ts/dispatch_queue.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/testnet-faucets/src/ts/dispatch_queue.ts b/packages/testnet-faucets/src/ts/dispatch_queue.ts
index 94d094203..672511619 100644
--- a/packages/testnet-faucets/src/ts/dispatch_queue.ts
+++ b/packages/testnet-faucets/src/ts/dispatch_queue.ts
@@ -1,6 +1,9 @@
import { intervalUtils } from '@0xproject/utils';
import * as _ from 'lodash';
+import { errorReporter } from './error_reporter';
+import { utils } from './utils';
+
const MAX_QUEUE_SIZE = 500;
const DEFAULT_QUEUE_INTERVAL_MS = 1000;
@@ -13,11 +16,11 @@ export class DispatchQueue {
this._queue = [];
this._start();
}
- public add(task: () => Promise<void>): boolean {
+ public add(taskAsync: () => Promise<void>): boolean {
if (this.isFull()) {
return false;
}
- this._queue.push(task);
+ this._queue.push(taskAsync);
return true;
}
public size(): number {
@@ -34,14 +37,18 @@ export class DispatchQueue {
private _start() {
this._queueIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
async () => {
- const task = this._queue.shift();
- if (_.isUndefined(task)) {
+ const taskAsync = this._queue.shift();
+ if (_.isUndefined(taskAsync)) {
return Promise.resolve();
}
- await task();
+ await taskAsync();
},
this._queueIntervalMs,
- _.noop,
+ (err: Error) => {
+ utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
+ // tslint:disable-next-line:no-floating-promises
+ errorReporter.reportAsync(err);
+ },
);
}
}