beefeeder 1.0.0
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/dist/index.d.ts +2 -0
- package/dist/index.js +45 -0
- package/package.json +24 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const bee_js_1 = require("@ethersphere/bee-js");
|
|
5
|
+
const cafe_utility_1 = require("cafe-utility");
|
|
6
|
+
const process_1 = require("process");
|
|
7
|
+
const GLOBAL_TIMEOUT_MINUTES = 5;
|
|
8
|
+
setTimeout(async () => {
|
|
9
|
+
console.log(`Script timed out after ${GLOBAL_TIMEOUT_MINUTES} minutes`);
|
|
10
|
+
await record('swarm.feed-10.total-millis', -1);
|
|
11
|
+
(0, process_1.exit)(1);
|
|
12
|
+
}, cafe_utility_1.Dates.minutes(GLOBAL_TIMEOUT_MINUTES));
|
|
13
|
+
const beeUrl = cafe_utility_1.Arrays.requireStringArgument(process.argv, 'bee-url');
|
|
14
|
+
const batchId = cafe_utility_1.Arrays.requireStringArgument(process.argv, 'batch');
|
|
15
|
+
const apiHost = cafe_utility_1.Arrays.requireStringArgument(process.argv, 'api-host');
|
|
16
|
+
const bee = new bee_js_1.Bee(beeUrl);
|
|
17
|
+
const privateKey = new bee_js_1.PrivateKey(cafe_utility_1.Strings.randomHex(64));
|
|
18
|
+
const owner = privateKey.publicKey().address().toHex();
|
|
19
|
+
const topic = bee_js_1.Topic.fromString(cafe_utility_1.Strings.randomHex(64));
|
|
20
|
+
const writer = bee.makeFeedWriter(topic, privateKey);
|
|
21
|
+
const reader = bee.makeFeedReader(topic, owner);
|
|
22
|
+
main();
|
|
23
|
+
async function main() {
|
|
24
|
+
const startedAt = Date.now();
|
|
25
|
+
for (let counter = 1; counter <= 10; counter++) {
|
|
26
|
+
const data = JSON.stringify({ counter });
|
|
27
|
+
await writer.uploadPayload(batchId, data);
|
|
28
|
+
await read(reader, counter);
|
|
29
|
+
}
|
|
30
|
+
const totalMillis = Date.now() - startedAt;
|
|
31
|
+
await record('swarm.feed-10.total-millis', totalMillis);
|
|
32
|
+
}
|
|
33
|
+
async function read(reader, expectedCounter) {
|
|
34
|
+
await cafe_utility_1.System.waitFor(async () => {
|
|
35
|
+
const feedUpdate = await reader.downloadPayload();
|
|
36
|
+
const data = feedUpdate.payload.toJSON();
|
|
37
|
+
return data.counter === expectedCounter;
|
|
38
|
+
}, { attempts: 600, waitMillis: cafe_utility_1.Dates.seconds(1) });
|
|
39
|
+
}
|
|
40
|
+
async function record(label, value) {
|
|
41
|
+
await fetch(cafe_utility_1.Strings.joinUrl([apiHost, `/observations/${label}/${value}`]), {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
signal: AbortSignal.timeout(cafe_utility_1.Dates.seconds(10))
|
|
44
|
+
});
|
|
45
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "beefeeder",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"beefeeder": "./dist/index.js"
|
|
6
|
+
},
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"check": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"description": "",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@ethersphere/bee-js": "^10.1.1",
|
|
18
|
+
"cafe-utility": "^33.3.2"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^24.10.1",
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
}
|
|
24
|
+
}
|