@toa.io/extensions.realtime 1.0.0-alpha.301 → 1.0.0-alpha.303
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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { Options } from '@toa.io/core/types'
|
|
5
5
|
import type { FetchInit } from '@toa.io/extensions.fetch'
|
|
6
6
|
import type { Stash } from '@toa.io/extensions.stash'
|
|
7
|
-
import type { Logs, Span } from '@toa.io/extensions.telemetry'
|
|
7
|
+
import type { Logs, Metrics, Span } from '@toa.io/extensions.telemetry'
|
|
8
8
|
|
|
9
9
|
export type CreateInput = {
|
|
10
10
|
key?: string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.realtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.303",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa Realtime",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"!**/.env*"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
30
|
-
"@toa.io/definitions": "1.0.0-alpha.
|
|
29
|
+
"@toa.io/core": "1.0.0-alpha.303",
|
|
30
|
+
"@toa.io/definitions": "1.0.0-alpha.303",
|
|
31
31
|
"@toa.io/generic": "1.0.0-alpha.301",
|
|
32
|
-
"openspan": "1.0.0-alpha.
|
|
32
|
+
"openspan": "1.0.0-alpha.303"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"transpile": "npx tsc && npx tsc -p ./components/realtime.streams",
|
|
36
36
|
"features": "TSX_TSCONFIG_PATH=features/steps/tsconfig.json NODE_OPTIONS=--import=tsx cucumber-js"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b8e9dd89f6d49756944687a95dfc786f12947286"
|
|
39
39
|
}
|
package/transpiled/Realtime.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { console, run } from 'openspan';
|
|
2
2
|
import { Connector } from '@toa.io/core';
|
|
3
|
+
import * as measure from './measurements.js';
|
|
3
4
|
export class Realtime extends Connector {
|
|
4
5
|
discovery;
|
|
5
6
|
streams = null;
|
|
@@ -24,7 +25,10 @@ export class Realtime extends Connector {
|
|
|
24
25
|
const processing = telemetry === null
|
|
25
26
|
? this.deliver(event)
|
|
26
27
|
: run(telemetry, async () => await this.deliver(event));
|
|
27
|
-
void processing.catch((error) =>
|
|
28
|
+
void processing.catch((error) => {
|
|
29
|
+
measure.failed(event.event);
|
|
30
|
+
console.error('Realtime push failed', error);
|
|
31
|
+
});
|
|
28
32
|
}
|
|
29
33
|
async deliver(event) {
|
|
30
34
|
/*
|
|
@@ -46,6 +50,7 @@ export class Realtime extends Connector {
|
|
|
46
50
|
};
|
|
47
51
|
await console.span(delivery, async () => await console.span(options, async () => {
|
|
48
52
|
await this.streams?.invoke('push', { input: event });
|
|
53
|
+
measure.delivered(event.event);
|
|
49
54
|
}));
|
|
50
55
|
}
|
|
51
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Realtime.js","sourceRoot":"","sources":["../source/Realtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Realtime.js","sourceRoot":"","sources":["../source/Realtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAE5C,MAAM,OAAO,QAAS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;QACH,MAAM,QAAQ,GAAG;YACf,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,UAAU;YAC9B,IAAI,EAAE,UAAmB;YACzB,OAAO,EAAE,KAAK,CAAC,KAAK;YACpB,UAAU,EAAE,EAAE,4BAA4B,EAAE,KAAK,CAAC,KAAK,EAAE;SAC1D,CAAA;QAED,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,OAAO;YAC3B,IAAI,EAAE,UAAmB;YACzB,OAAO,EAAE,UAAU;YACnB,UAAU,EAAE,EAAE,4BAA4B,EAAE,KAAK,CAAC,KAAK,EAAE;SAC1D,CAAA;QAED,MAAM,OAAO,CAAC,IAAI,CAChB,QAAQ,EACR,KAAK,IAAI,EAAE,CACT,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACrC,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;YAEpD,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAChC,CAAC,CAAC,CACL,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { registry } from 'openspan';
|
|
2
|
+
/**
|
|
3
|
+
* What realtime measures, per event — which is the whole reason it exists. The push itself is an
|
|
4
|
+
* operation invocation and core counts it, but by component and operation, where the event is the
|
|
5
|
+
* input and invisible. Here it is the label, and that is what makes the comparison possible:
|
|
6
|
+
* `toa.event.publish.duration._count` against this is published versus arrived.
|
|
7
|
+
*/
|
|
8
|
+
const meters = registry();
|
|
9
|
+
const pushed = meters.counter('toa.realtime.pushed', { event: null });
|
|
10
|
+
/** A push failure is swallowed into a log line and nothing else. */
|
|
11
|
+
const failures = meters.counter('toa.realtime.failures', { event: null });
|
|
12
|
+
export function delivered(event) {
|
|
13
|
+
pushed.add(1, { event });
|
|
14
|
+
}
|
|
15
|
+
export function failed(event) {
|
|
16
|
+
failures.add(1, { event });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=measurements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measurements.js","sourceRoot":"","sources":["../source/measurements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAA;AAEzB,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAErE,oEAAoE;AACpE,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAEzE,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AAC5B,CAAC"}
|