Feature/gather enhancements (#73)

* add bargein support to gather

* bugfix: gather handles interim results from azure

* gather: support for min/max digits and interdigit timeout

* add task summary to some log messages

* logging improvements
This commit is contained in:
Dave Horton
2022-02-27 13:38:02 -05:00
committed by GitHub
parent 3c5d392407
commit f317fbaa45
8 changed files with 160 additions and 45 deletions

View File

@@ -1,3 +1,3 @@
module.exports = function(tasks) {
return `[${tasks.map((t) => t.name).join(',')}]`;
return `[${tasks.map((t) => t.summary).join(',')}]`;
};

View File

@@ -58,7 +58,7 @@ class WsRequestor extends BaseRequestor {
const rtt = this._roundTrip(startAt);
this.stats.histogram('app.hook.connect_time', rtt, ['hook_type:app']);
} catch (err) {
this.logger.error({err}, 'WsRequestor:request - failed connecting');
this.logger.info({url, err}, 'WsRequestor:request - failed connecting');
throw err;
}
}
@@ -137,11 +137,12 @@ class WsRequestor extends BaseRequestor {
.once('ready', (ws) => {
this.ws = ws;
this.removeAllListeners('not-ready');
this.connections++;
resolve();
})
.once('not-ready', () => {
.once('not-ready', (err) => {
this.removeAllListeners('ready');
reject();
reject(err);
});
const ws = new Websocket(this.url, ['ws.jambonz.org'], opts);
this._setHandlers(ws);
@@ -158,9 +159,11 @@ class WsRequestor extends BaseRequestor {
}
_onError(err) {
this.logger.info({url: this.url, err}, 'WsRequestor:_onError');
if (this.connections > 0) this.emit('socket-closed');
this.emit('not-ready');
if (this.connections > 0) {
this.logger.info({url: this.url, err}, 'WsRequestor:_onError');
if (this.connections > 0) this.emit('socket-closed');
}
else this.emit('not-ready', err);
}
_onOpen(ws) {
@@ -170,8 +173,10 @@ class WsRequestor extends BaseRequestor {
}
_onClose() {
this.logger.info({url: this.url}, 'WsRequestor - socket closed unexpectedly from remote side');
this.emit('socket-closed');
if (this.connections > 0) {
this.logger.info({url: this.url}, 'WsRequestor - socket closed unexpectedly from remote side');
this.emit('socket-closed');
}
}
_onUnexpectedResponse(ws, req, res) {
@@ -182,7 +187,7 @@ class WsRequestor extends BaseRequestor {
statusMessage: res.statusMessage
}, 'WsRequestor - unexpected response');
this.emit('connection-failure');
this.emit('not-ready');
this.emit('not-ready', new Error(`${res.statusCode} ${res.statusMessage}`));
}
_onSocketClosed() {