@sera4/essentia 1.0.30 → 1.0.31
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/package.json +1 -1
- package/package.tar.gz +0 -0
- package/queue/index.js +19 -27
package/package.json
CHANGED
package/package.tar.gz
CHANGED
|
Binary file
|
package/queue/index.js
CHANGED
|
@@ -17,35 +17,27 @@ class S4Queue {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Tests the connection to the service.
|
|
21
|
+
* Internally, the same connection is used for test
|
|
22
|
+
* and production code, but a separate channel is opened.
|
|
23
|
+
* Once the channel is obtained, there is an assert on the
|
|
24
|
+
* existence of a topic exchange called '--health-check--'.
|
|
25
|
+
* The following must be satisfied for the test to pass
|
|
26
|
+
* 1. must be connected
|
|
27
|
+
* 2. must have a test channel
|
|
28
|
+
* 3. must assert the exchange
|
|
23
29
|
*/
|
|
24
|
-
async testConnection(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// To avoid any issues, let's parse the url
|
|
29
|
-
// and provide the server name in the socket options
|
|
30
|
-
const urlParts = urlParse(options.connectionUrl);
|
|
31
|
-
const socketOptions = {servername: urlParts.hostname};
|
|
30
|
+
async testConnection() {
|
|
31
|
+
if (!this.isConnected()) {
|
|
32
|
+
throw("queue service not connected")
|
|
33
|
+
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
conn.close(e => {
|
|
41
|
-
if (e) {
|
|
42
|
-
reject(e)
|
|
43
|
-
} else {
|
|
44
|
-
resolve(true)
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
});
|
|
35
|
+
this.connectionTestChannel = this.connectionTestChannel || await this.connection.createChannel();
|
|
36
|
+
if (!this.connectionTestChannel) {
|
|
37
|
+
throw("queue service failed to obtain a channel")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await this.connectionTestChannel.assertExchange("--health-check--", "topic", {durable: false});
|
|
49
41
|
}
|
|
50
42
|
|
|
51
43
|
/**
|