elasticio-sailor-nodejs 3.0.0-sailor-proxy-dev20 → 3.0.0-sailor-proxy-dev21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/lib/proxy-client.js +7 -15
- package/lib/settings.js +0 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/lib/proxy-client.js
CHANGED
|
@@ -399,6 +399,7 @@ class ProxyClient {
|
|
|
399
399
|
chunks.push(chunk);
|
|
400
400
|
});
|
|
401
401
|
getObjectStream.on('error', (err) => {
|
|
402
|
+
// TODO: handle error responses
|
|
402
403
|
logger.error(err, 'Error during fetching message body');
|
|
403
404
|
reject(err);
|
|
404
405
|
});
|
|
@@ -406,7 +407,7 @@ class ProxyClient {
|
|
|
406
407
|
logger.info('Message stream ended by server');
|
|
407
408
|
const buffer = Buffer.concat(chunks);
|
|
408
409
|
logger.info({ messageSize: buffer.length }, 'Received complete message from server');
|
|
409
|
-
resolve(
|
|
410
|
+
resolve(JSON.parse(buffer.toString()));
|
|
410
411
|
});
|
|
411
412
|
}));
|
|
412
413
|
|
|
@@ -614,7 +615,6 @@ class ProxyClient {
|
|
|
614
615
|
...metadata,
|
|
615
616
|
messageId: metadata.messageId || uuid.v4()
|
|
616
617
|
};
|
|
617
|
-
delete preparedMetadata.reboundIteration;
|
|
618
618
|
let preparedData = data;
|
|
619
619
|
if (preparedData && preparedData.headers) {
|
|
620
620
|
preparedData.headers = _.omitBy(
|
|
@@ -657,12 +657,6 @@ class ProxyClient {
|
|
|
657
657
|
}, 'Sending message to proxy');
|
|
658
658
|
log.trace({ data }, 'Message data to send to proxy');
|
|
659
659
|
const { preparedMetadata, preparedData } = this._prepareData(data, metadata, type, forceProtocolVersion);
|
|
660
|
-
if (preparedData && preparedData.length > this.settings.OUTGOING_MESSAGE_SIZE_LIMIT) {
|
|
661
|
-
const error = new Error(`Outgoing message size ${preparedData.length}` +
|
|
662
|
-
` exceeds limit of ${this.settings.OUTGOING_MESSAGE_SIZE_LIMIT}.`);
|
|
663
|
-
log.error(error);
|
|
664
|
-
throw error;
|
|
665
|
-
}
|
|
666
660
|
log.debug({ preparedMetadata, preparedDataSize: preparedData ? preparedData.length : null }, 'Prepared message for sending to proxy');
|
|
667
661
|
|
|
668
662
|
const queryParams = new URLSearchParams({
|
|
@@ -683,6 +677,7 @@ class ProxyClient {
|
|
|
683
677
|
postMessageStream.end();
|
|
684
678
|
|
|
685
679
|
postMessageStream.on('response', (headers) => {
|
|
680
|
+
// TODO: handle error responses
|
|
686
681
|
log.debug({ status: headers[HTTP2_HEADER_STATUS] }, 'Send message response');
|
|
687
682
|
if (headers[HTTP2_HEADER_STATUS] !== 200) {
|
|
688
683
|
log.error({ headers }, 'Failed to send message');
|
|
@@ -746,13 +741,12 @@ class ProxyClient {
|
|
|
746
741
|
if (Object.values(MESSAGE_PROCESSING_STATUS).indexOf(status) === -1) {
|
|
747
742
|
throw new Error(`Invalid message processing status: ${status}`);
|
|
748
743
|
}
|
|
749
|
-
const { messageId: incomingMessageId
|
|
750
|
-
log.debug({ incomingMessageId, status
|
|
744
|
+
const { messageId: incomingMessageId } = metadata;
|
|
745
|
+
log.debug({ incomingMessageId, status }, 'Finishing processing of message');
|
|
751
746
|
const queryParams = new URLSearchParams({
|
|
752
747
|
clientId: this.proxyClientId,
|
|
753
748
|
incomingMessageId,
|
|
754
|
-
status
|
|
755
|
-
...(typeof reboundIteration !== 'undefined' ? { reboundIteration } : {})
|
|
749
|
+
status
|
|
756
750
|
}).toString();
|
|
757
751
|
|
|
758
752
|
await this._proxyRequestWithRetries('Finish processing', () => new Promise((resolve, reject) => {
|
|
@@ -764,6 +758,7 @@ class ProxyClient {
|
|
|
764
758
|
postMessageStream.end();
|
|
765
759
|
|
|
766
760
|
postMessageStream.on('response', (headers) => {
|
|
761
|
+
// TODO: handle error responses
|
|
767
762
|
log.debug({ status: headers[HTTP2_HEADER_STATUS] }, 'Finish processing response event');
|
|
768
763
|
if (headers[HTTP2_HEADER_STATUS] !== 200) {
|
|
769
764
|
log.error({ headers }, 'Failed to finish processing message');
|
|
@@ -893,9 +888,6 @@ class ProxyClient {
|
|
|
893
888
|
if (parsedMessageMetadata.reply_to) {
|
|
894
889
|
result.reply_to = parsedMessageMetadata.reply_to;
|
|
895
890
|
}
|
|
896
|
-
if (parsedMessageMetadata.reboundIteration) {
|
|
897
|
-
result.reboundIteration = parsedMessageMetadata.reboundIteration;
|
|
898
|
-
}
|
|
899
891
|
log.debug({ result }, 'Extracted message metadata');
|
|
900
892
|
return result;
|
|
901
893
|
}
|
package/lib/settings.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elasticio-sailor-nodejs",
|
|
3
3
|
"description": "The official elastic.io library for bootstrapping and executing for Node.js connectors",
|
|
4
|
-
"version": "3.0.0-sailor-proxy-
|
|
4
|
+
"version": "3.0.0-sailor-proxy-dev21",
|
|
5
5
|
"main": "run.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"debug": "3.1.0",
|
|
24
24
|
"elasticio-rest-node": "2.0.0",
|
|
25
25
|
"event-to-promise": "0.8.0",
|
|
26
|
-
"jsonwebtoken": "
|
|
27
|
-
"lodash": "4.
|
|
26
|
+
"jsonwebtoken": "9.0.3",
|
|
27
|
+
"lodash": "4.18.1",
|
|
28
28
|
"p-throttle": "2.1.0",
|
|
29
29
|
"q": "1.5.1",
|
|
30
30
|
"uuid": "3.0.1"
|