@certik/skynet 0.10.12 → 0.10.13
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 +8 -0
- package/ably.js +16 -5
- package/examples/api +0 -0
- package/examples/consumer +0 -0
- package/examples/indexer +0 -0
- package/examples/mode-indexer +0 -0
- package/examples/producer +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.13
|
|
4
|
+
|
|
5
|
+
- Initialize Ably after user request publishing messages
|
|
6
|
+
|
|
7
|
+
- Increase wait time for Ably message sending bottleneck
|
|
8
|
+
|
|
9
|
+
- Update packages
|
|
10
|
+
|
|
3
11
|
## 0.10.12
|
|
4
12
|
|
|
5
13
|
- Fixed distributed lock name for `producer` and `api` type apps
|
package/ably.js
CHANGED
|
@@ -2,12 +2,23 @@ const Ably = require("ably");
|
|
|
2
2
|
const Bottleneck = require("bottleneck/es5");
|
|
3
3
|
const { ensureAndGet } = require("./env");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
let ABLY;
|
|
6
|
+
|
|
7
|
+
async function getAbly() {
|
|
8
|
+
if (!ABLY) {
|
|
9
|
+
ABLY = await new Promise((resolve) => {
|
|
10
|
+
const ably = new Ably.Realtime(ensureAndGet("ABLY_ROOT_API_KEY"));
|
|
11
|
+
ably.connection.on("connected", () => {
|
|
12
|
+
console.log("ably connection successful");
|
|
13
|
+
resolve(ably);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return ABLY;
|
|
18
|
+
}
|
|
9
19
|
|
|
10
20
|
async function publishMessage(channel, messageName, messageData) {
|
|
21
|
+
const ably = await getAbly();
|
|
11
22
|
const channelObj = ably.channels.get(channel);
|
|
12
23
|
|
|
13
24
|
const messageDataJson = JSON.stringify(messageData);
|
|
@@ -20,7 +31,7 @@ async function publishMessage(channel, messageName, messageData) {
|
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
const rateLimitedPublishMessage = new Bottleneck({
|
|
23
|
-
minTime: 1000 /
|
|
34
|
+
minTime: 1000 / 60,
|
|
24
35
|
}).wrap(publishMessage);
|
|
25
36
|
|
|
26
37
|
module.exports = {
|
package/examples/api
CHANGED
|
File without changes
|
package/examples/consumer
CHANGED
|
File without changes
|
package/examples/indexer
CHANGED
|
File without changes
|
package/examples/mode-indexer
CHANGED
|
File without changes
|
package/examples/producer
CHANGED
|
File without changes
|