@certik/skynet 0.10.7 → 0.10.8

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.
@@ -1,82 +1,82 @@
1
- #!/usr/bin/env node
2
-
3
- // this file is executable and is for kafka producer testing
4
- // a few test commands to try on
5
- // $ examples/mode-indexer run --protocol bsc --verbose
6
- // $ examples/mode-indexer run --mode rebuild --protocol bsc --verbose
7
- // $ examples/mode-indexer run --protocol eth
8
- // $ examples/mode-indexer check --protocol eth
9
- // $ examples/mode-indexer deploy --protocol eth
10
- // $ examples/mode-indexer --help
11
-
12
- const { modeIndexer, every, SENSITIVE_VALUE } = require("../app");
13
-
14
- async function build({ protocol, from, to, verbose }) {
15
- console.log("build called with", protocol, from, to, verbose);
16
- }
17
-
18
- async function validate({ protocol, from, to, verbose }) {
19
- console.log("validate called with", protocol, from, to, verbose);
20
- }
21
-
22
- async function check({ mode, protocol, state, verbose }) {
23
- console.log("check called with", mode, protocol, state, verbose);
24
-
25
- const errors = [];
26
-
27
- // if (state.latestId < getBlockLatestHeight(protocol)) {
28
- // errors.push({ type: ERROR_LEVEL.INFO, message: "processed height lagged behind" });
29
- // }
30
-
31
- return errors;
32
- }
33
-
34
- const app = modeIndexer({
35
- name: "example-mode-indexer",
36
-
37
- selector: {
38
- // for more flags check meow documentation at https://github.com/sindresorhus/meow
39
- protocol: {
40
- type: "string",
41
- description: "which chain to index",
42
- },
43
- },
44
-
45
- env: {},
46
-
47
- state: {
48
- type: "block", // can be omitted, default is block
49
- getMinId: async () => 2, // default returns 1
50
- getMaxId: async ({ protocol }) => {
51
- return 10;
52
- },
53
- },
54
-
55
- build: {
56
- func: build,
57
- batchSize: 5,
58
- concurrency: 2, // default is 1, no concurrency
59
-
60
- schedule: every(1).minute,
61
- cpu: 800,
62
- mem: 400,
63
- },
64
-
65
- validate: {
66
- func: validate,
67
- batchSize: 2,
68
- concurrency: 2, // default is 1, no concurrency
69
-
70
- schedule: every(1).hour,
71
- cpu: 600,
72
- mem: 200,
73
- },
74
-
75
- check: {
76
- func: check,
77
- schedule: every(2).minutes,
78
- slackChannel: "skynet-notifications-local-dev",
79
- },
80
- });
81
-
82
- app();
1
+ #!/usr/bin/env node
2
+
3
+ // this file is executable and is for kafka producer testing
4
+ // a few test commands to try on
5
+ // $ examples/mode-indexer run --protocol bsc --verbose
6
+ // $ examples/mode-indexer run --mode rebuild --protocol bsc --verbose
7
+ // $ examples/mode-indexer run --protocol eth
8
+ // $ examples/mode-indexer check --protocol eth
9
+ // $ examples/mode-indexer deploy --protocol eth
10
+ // $ examples/mode-indexer --help
11
+
12
+ const { modeIndexer, every, SENSITIVE_VALUE } = require("../app");
13
+
14
+ async function build({ protocol, from, to, verbose }) {
15
+ console.log("build called with", protocol, from, to, verbose);
16
+ }
17
+
18
+ async function validate({ protocol, from, to, verbose }) {
19
+ console.log("validate called with", protocol, from, to, verbose);
20
+ }
21
+
22
+ async function check({ mode, protocol, state, verbose }) {
23
+ console.log("check called with", mode, protocol, state, verbose);
24
+
25
+ const errors = [];
26
+
27
+ // if (state.latestId < getBlockLatestHeight(protocol)) {
28
+ // errors.push({ type: ERROR_LEVEL.INFO, message: "processed height lagged behind" });
29
+ // }
30
+
31
+ return errors;
32
+ }
33
+
34
+ const app = modeIndexer({
35
+ name: "example-mode-indexer",
36
+
37
+ selector: {
38
+ // for more flags check meow documentation at https://github.com/sindresorhus/meow
39
+ protocol: {
40
+ type: "string",
41
+ description: "which chain to index",
42
+ },
43
+ },
44
+
45
+ env: {},
46
+
47
+ state: {
48
+ type: "block", // can be omitted, default is block
49
+ getMinId: async () => 2, // default returns 1
50
+ getMaxId: async ({ protocol }) => {
51
+ return 10;
52
+ },
53
+ },
54
+
55
+ build: {
56
+ func: build,
57
+ batchSize: 5,
58
+ concurrency: 2, // default is 1, no concurrency
59
+
60
+ schedule: every(1).minute,
61
+ cpu: 800,
62
+ mem: 400,
63
+ },
64
+
65
+ validate: {
66
+ func: validate,
67
+ batchSize: 2,
68
+ concurrency: 2, // default is 1, no concurrency
69
+
70
+ schedule: every(1).hour,
71
+ cpu: 600,
72
+ mem: 200,
73
+ },
74
+
75
+ check: {
76
+ func: check,
77
+ schedule: every(2).minutes,
78
+ slackChannel: "skynet-notifications-local-dev",
79
+ },
80
+ });
81
+
82
+ app();
package/examples/producer CHANGED
@@ -1,80 +1,80 @@
1
- #!/usr/bin/env node
2
-
3
- // this file is executable and is for kafka producer testing
4
- // a few test commands to try on
5
- // $ examples/producer run --protocol bsc --verbose
6
- // $ examples/producer run --protocol eth
7
- // $ examples/producer check --protocol eth
8
- // $ examples/producer deploy --protocol eth
9
- // $ examples/producer --help
10
-
11
- const { producer, every, SENSITIVE_VALUE, ERROR_LEVEL } = require("../app");
12
-
13
- async function produce({ protocol, from, to, verbose, send }) {
14
- console.log("produce called with", protocol, from, to, verbose);
15
-
16
- const items = [];
17
- for (let i = from; i <= to; i++) {
18
- items.push({ id: i, name: `${protocol} User ${i}` });
19
- }
20
-
21
- await send(items);
22
- }
23
-
24
- async function check({ protocol, state, verbose }) {
25
- console.log("check called with", protocol, state, verbose);
26
-
27
- const errors = [];
28
-
29
- errors.push({ type: ERROR_LEVEL.CRITICAL, message: "producer error" });
30
-
31
- return errors;
32
- }
33
-
34
- const app = producer({
35
- name: "example-producer",
36
- selector: { protocol: { type: "string", description: "for which chain to produce data" } },
37
-
38
- env: {
39
- // sensitive value will be loaded from:
40
- // local: process.env.HOME
41
- // production: the secrets store on nomad cluster
42
- // your local env value won't be uploaded to production
43
- HOME: SENSITIVE_VALUE,
44
- // concrete value is good for insensitive configuration
45
- // the value is the same for local and production
46
- TEST: "abcdefg",
47
- },
48
-
49
- state: {
50
- type: "block", // can be omitted, default is block
51
- updateInterval: ({ protocol }) => (protocol === "bsc" ? 3000 : 20000), // how often max id is increasing, will determine poll interval, default to 5000ms
52
- getMinId: async () => 4, // default returns 1
53
- getMaxId: async ({ protocol }) => {
54
- console.log("getMaxId called", protocol);
55
-
56
- return 100;
57
- },
58
- },
59
-
60
- produce: {
61
- func: produce,
62
-
63
- topic: ({ protocol }) => `lib-skynet-test-kafka-${protocol}-dev`,
64
- deadLetterTopic: ({ protocol }) => `lib-skynet-test-kafka-${protocol}-dead-letter-dev`, // problematic ids will be sent to dead letter topic for later retry
65
-
66
- batchSize: 10, // default 50
67
- maxRetry: 1, // default 2
68
-
69
- cpu: 600,
70
- mem: 200,
71
- },
72
-
73
- check: {
74
- func: check,
75
- schedule: every(2).minutes,
76
- slackChannel: "skynet-notifications-local-dev",
77
- },
78
- });
79
-
80
- app();
1
+ #!/usr/bin/env node
2
+
3
+ // this file is executable and is for kafka producer testing
4
+ // a few test commands to try on
5
+ // $ examples/producer run --protocol bsc --verbose
6
+ // $ examples/producer run --protocol eth
7
+ // $ examples/producer check --protocol eth
8
+ // $ examples/producer deploy --protocol eth
9
+ // $ examples/producer --help
10
+
11
+ const { producer, every, SENSITIVE_VALUE, ERROR_LEVEL } = require("../app");
12
+
13
+ async function produce({ protocol, from, to, verbose, send }) {
14
+ console.log("produce called with", protocol, from, to, verbose);
15
+
16
+ const items = [];
17
+ for (let i = from; i <= to; i++) {
18
+ items.push({ id: i, name: `${protocol} User ${i}` });
19
+ }
20
+
21
+ await send(items);
22
+ }
23
+
24
+ async function check({ protocol, state, verbose }) {
25
+ console.log("check called with", protocol, state, verbose);
26
+
27
+ const errors = [];
28
+
29
+ errors.push({ type: ERROR_LEVEL.CRITICAL, message: "producer error" });
30
+
31
+ return errors;
32
+ }
33
+
34
+ const app = producer({
35
+ name: "example-producer",
36
+ selector: { protocol: { type: "string", description: "for which chain to produce data" } },
37
+
38
+ env: {
39
+ // sensitive value will be loaded from:
40
+ // local: process.env.HOME
41
+ // production: the secrets store on nomad cluster
42
+ // your local env value won't be uploaded to production
43
+ HOME: SENSITIVE_VALUE,
44
+ // concrete value is good for insensitive configuration
45
+ // the value is the same for local and production
46
+ TEST: "abcdefg",
47
+ },
48
+
49
+ state: {
50
+ type: "block", // can be omitted, default is block
51
+ updateInterval: ({ protocol }) => (protocol === "bsc" ? 3000 : 20000), // how often max id is increasing, will determine poll interval, default to 5000ms
52
+ getMinId: async () => 4, // default returns 1
53
+ getMaxId: async ({ protocol }) => {
54
+ console.log("getMaxId called", protocol);
55
+
56
+ return 100;
57
+ },
58
+ },
59
+
60
+ produce: {
61
+ func: produce,
62
+
63
+ topic: ({ protocol }) => `lib-skynet-test-kafka-${protocol}-dev`,
64
+ deadLetterTopic: ({ protocol }) => `lib-skynet-test-kafka-${protocol}-dead-letter-dev`, // problematic ids will be sent to dead letter topic for later retry
65
+
66
+ batchSize: 10, // default 50
67
+ maxRetry: 1, // default 2
68
+
69
+ cpu: 600,
70
+ mem: 200,
71
+ },
72
+
73
+ check: {
74
+ func: check,
75
+ schedule: every(2).minutes,
76
+ slackChannel: "skynet-notifications-local-dev",
77
+ },
78
+ });
79
+
80
+ app();