@toa.io/extensions.realtime 1.0.0-alpha.208 → 1.0.0-alpha.212
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/components/streams/manifest.toa.yaml +12 -0
- package/components/streams/operations/create.d.ts +2 -0
- package/components/streams/operations/create.js +30 -9
- package/components/streams/operations/create.js.map +1 -1
- package/components/streams/operations/lib/Stash.d.ts +20 -0
- package/components/streams/operations/lib/Stash.js +71 -0
- package/components/streams/operations/lib/Stash.js.map +1 -0
- package/components/streams/operations/lib/index.d.ts +2 -0
- package/components/streams/operations/lib/index.js +8 -0
- package/components/streams/operations/lib/index.js.map +1 -0
- package/components/streams/operations/lib/types.d.ts +8 -0
- package/components/streams/operations/push.js +6 -0
- package/components/streams/operations/push.js.map +1 -1
- package/components/streams/operations/tsconfig.tsbuildinfo +1 -1
- package/components/streams/source/create.ts +42 -10
- package/components/streams/source/lib/Stash.ts +105 -0
- package/components/streams/source/lib/index.ts +2 -0
- package/components/streams/source/lib/types.ts +8 -0
- package/components/streams/source/push.ts +7 -0
- package/features/static.feature +48 -0
- package/features/steps/Realtime.ts +1 -1
- package/features/steps/Streams.ts +40 -6
- package/package.json +3 -3
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -5,6 +5,7 @@ operations:
|
|
|
5
5
|
create:
|
|
6
6
|
input:
|
|
7
7
|
key: string
|
|
8
|
+
token: string
|
|
8
9
|
push:
|
|
9
10
|
bindings: ~ # only for internal use
|
|
10
11
|
input:
|
|
@@ -12,7 +13,18 @@ operations:
|
|
|
12
13
|
event*: string
|
|
13
14
|
data: ~
|
|
14
15
|
|
|
16
|
+
configuration:
|
|
17
|
+
schema:
|
|
18
|
+
properties:
|
|
19
|
+
maxlen:
|
|
20
|
+
type: number
|
|
21
|
+
default: 1000
|
|
22
|
+
expire:
|
|
23
|
+
type: number
|
|
24
|
+
default: 300
|
|
25
|
+
|
|
15
26
|
state: ~
|
|
27
|
+
stash: ~
|
|
16
28
|
|
|
17
29
|
exposition:
|
|
18
30
|
/:key:
|
|
@@ -4,6 +4,7 @@ import { type Operation } from '@toa.io/types';
|
|
|
4
4
|
import { type Context } from './lib/types';
|
|
5
5
|
export declare class Effect implements Operation {
|
|
6
6
|
private readonly streams;
|
|
7
|
+
private stash;
|
|
7
8
|
private logs;
|
|
8
9
|
mount(context: Context): void;
|
|
9
10
|
unmount(): void;
|
|
@@ -12,5 +13,6 @@ export declare class Effect implements Operation {
|
|
|
12
13
|
}
|
|
13
14
|
interface Input {
|
|
14
15
|
key: string;
|
|
16
|
+
token?: string;
|
|
15
17
|
}
|
|
16
18
|
export {};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Effect = void 0;
|
|
4
|
-
const
|
|
4
|
+
const lib_1 = require("./lib");
|
|
5
5
|
class Effect {
|
|
6
6
|
streams = new Map();
|
|
7
|
+
stash;
|
|
7
8
|
logs;
|
|
8
9
|
mount(context) {
|
|
9
10
|
context.state.streams = this.streams;
|
|
11
|
+
context.state.stash = new lib_1.Stash(context.stash, context.configuration);
|
|
10
12
|
this.logs = context.logs;
|
|
13
|
+
this.stash = context.state.stash;
|
|
11
14
|
}
|
|
12
15
|
unmount() {
|
|
13
16
|
this.logs.info('Destroying streams', { count: this.streams.size });
|
|
@@ -16,20 +19,38 @@ class Effect {
|
|
|
16
19
|
}
|
|
17
20
|
async execute(input) {
|
|
18
21
|
const key = input.key;
|
|
19
|
-
let stream;
|
|
20
22
|
if (!this.streams.has(key)) {
|
|
21
|
-
stream = this.createStream(key);
|
|
23
|
+
const stream = this.createStream(key);
|
|
24
|
+
this.streams.set(key, stream);
|
|
22
25
|
this.logs.debug('Stream created', { key });
|
|
23
26
|
}
|
|
24
|
-
else
|
|
25
|
-
stream = this.streams.get(key);
|
|
26
27
|
// welcome
|
|
27
|
-
setTimeout(() =>
|
|
28
|
-
|
|
28
|
+
setTimeout(() => this.streams.get(key)?.heartbeat(), 1000);
|
|
29
|
+
if (input.token === undefined)
|
|
30
|
+
void this.stash.connect(key).then((token) => {
|
|
31
|
+
if (token instanceof Error)
|
|
32
|
+
this.logs.error('Failed to connect to stash', { key, error: token });
|
|
33
|
+
else
|
|
34
|
+
this.streams.get(key)?.push({ event: 'token', data: token });
|
|
35
|
+
});
|
|
36
|
+
else
|
|
37
|
+
void this.stash.pop(key, input.token).then((result) => {
|
|
38
|
+
if (result instanceof Error)
|
|
39
|
+
this.logs.error('Failed to pop from stash', { key, error: result });
|
|
40
|
+
else if (result !== null) {
|
|
41
|
+
const stream = this.streams.get(key);
|
|
42
|
+
if (stream === undefined)
|
|
43
|
+
return;
|
|
44
|
+
const [token, events] = result;
|
|
45
|
+
for (const event of events)
|
|
46
|
+
stream.push({ event: event.event, data: event.data });
|
|
47
|
+
stream.push({ event: 'token', data: token });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return this.streams.get(key);
|
|
29
51
|
}
|
|
30
52
|
createStream(key) {
|
|
31
|
-
const stream = new
|
|
32
|
-
this.streams.set(key, stream);
|
|
53
|
+
const stream = new lib_1.Stream();
|
|
33
54
|
stream.events.once('destroy', () => {
|
|
34
55
|
this.logs.debug('Stream destroyed', { key });
|
|
35
56
|
this.streams.delete(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../source/create.ts"],"names":[],"mappings":";;;AAGA
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../source/create.ts"],"names":[],"mappings":";;;AAGA,+BAAqC;AAErC,MAAa,MAAM;IACA,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC5C,KAAK,CAAQ;IACb,IAAI,CAAK;IAEV,KAAK,CAAE,OAAgB;QAC5B,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QACpC,OAAO,CAAC,KAAK,CAAC,KAA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GAAG,EAAE;YACjC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;YAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAxED,wBAwEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Stash {
|
|
2
|
+
private readonly stash;
|
|
3
|
+
private readonly configuration;
|
|
4
|
+
constructor(stash: any, configuration: Configuration);
|
|
5
|
+
connect(key: string): Promise<string | Error>;
|
|
6
|
+
push(key: string, event: string, data: unknown): Promise<string | Error>;
|
|
7
|
+
pop(key: string, token: string): Promise<[string, Event[]] | null | Error>;
|
|
8
|
+
private xadd;
|
|
9
|
+
private encode;
|
|
10
|
+
private decode;
|
|
11
|
+
}
|
|
12
|
+
interface Configuration {
|
|
13
|
+
maxlen: number;
|
|
14
|
+
expire: number;
|
|
15
|
+
}
|
|
16
|
+
interface Event {
|
|
17
|
+
event: string;
|
|
18
|
+
data: unknown;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Stash = void 0;
|
|
4
|
+
class Stash {
|
|
5
|
+
stash;
|
|
6
|
+
configuration;
|
|
7
|
+
constructor(stash, configuration) {
|
|
8
|
+
this.stash = stash;
|
|
9
|
+
this.configuration = configuration;
|
|
10
|
+
}
|
|
11
|
+
async connect(key) {
|
|
12
|
+
return await this.xadd(key, 'connect');
|
|
13
|
+
}
|
|
14
|
+
async push(key, event, data) {
|
|
15
|
+
return await this.xadd(key, event, data);
|
|
16
|
+
}
|
|
17
|
+
async pop(key, token) {
|
|
18
|
+
const stamp = this.decode(token);
|
|
19
|
+
const results = await this.stash
|
|
20
|
+
.xread('STREAMS', key, stamp)
|
|
21
|
+
.catch((error) => error);
|
|
22
|
+
if (results === null)
|
|
23
|
+
return ERR_NO_RESULTS;
|
|
24
|
+
if (results instanceof Error)
|
|
25
|
+
return results;
|
|
26
|
+
if (results.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
const [, items] = results[0];
|
|
29
|
+
const events = [];
|
|
30
|
+
let lastStamp = null;
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
const [, event, , json] = item[1];
|
|
33
|
+
lastStamp = item[0];
|
|
34
|
+
events.push({ event, data: JSON.parse(json) });
|
|
35
|
+
}
|
|
36
|
+
if (lastStamp === null)
|
|
37
|
+
return null;
|
|
38
|
+
return [this.encode(lastStamp), events];
|
|
39
|
+
}
|
|
40
|
+
async xadd(key, event, data) {
|
|
41
|
+
const args = ['MAXLEN', '~', this.configuration.maxlen, '*', 'type', event];
|
|
42
|
+
if (data !== undefined)
|
|
43
|
+
args.push('data', JSON.stringify(data));
|
|
44
|
+
const results = await this.stash
|
|
45
|
+
.multi()
|
|
46
|
+
.xadd(key, ...args)
|
|
47
|
+
.expire(key, this.configuration.expire)
|
|
48
|
+
.exec()
|
|
49
|
+
.catch((error) => error);
|
|
50
|
+
if (results === null)
|
|
51
|
+
return ERR_NO_RESULTS;
|
|
52
|
+
if (results instanceof Error)
|
|
53
|
+
return results;
|
|
54
|
+
const [[error, stamp]] = results;
|
|
55
|
+
if (error !== null)
|
|
56
|
+
return error;
|
|
57
|
+
return this.encode(stamp);
|
|
58
|
+
}
|
|
59
|
+
encode(token) {
|
|
60
|
+
return Buffer.from(token).toString('base64url');
|
|
61
|
+
}
|
|
62
|
+
decode(token) {
|
|
63
|
+
return Buffer.from(token, 'base64url').toString();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Stash = Stash;
|
|
67
|
+
class NoResultsError extends Error {
|
|
68
|
+
code = 'NO_RESULTS';
|
|
69
|
+
}
|
|
70
|
+
const ERR_NO_RESULTS = new NoResultsError();
|
|
71
|
+
//# s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I;YAChB,OAAO,KAAK,CAAA;QAEd,OAAO,IAAI,CAAC,MAAM,CAAC,KAAe,CAAC,CAAA;IACrC,CAAC;IAEO,MAAM,CAAE,KAAa;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACjD,CAAC;IAEO,MAAM,CAAE,KAAa;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAA;IACnD,CAAC;CACF;AAtFD,sBAsFC;AAYD,MAAM,cAAe,SAAQ,KAAK;IAChB,IAAI,GAAG,YAAY,CAAA;CACpC;AAED,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Stream = exports.Stash = void 0;
|
|
4
|
+
var Stash_1 = require("./Stash");
|
|
5
|
+
Object.defineProperty(exports, "Stash", { enumerable: true, get: function () { return Stash_1.Stash; } });
|
|
6
|
+
var Stream_1 = require("./Stream");
|
|
7
|
+
Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return Stream_1.Stream; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/lib/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,mCAAiC;AAAxB,gGAAA,MAAM,OAAA"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { type Stream } from './Stream';
|
|
2
|
+
import { type Stash } from './Stash';
|
|
2
3
|
export interface Context {
|
|
4
|
+
stash: any;
|
|
3
5
|
state: {
|
|
4
6
|
streams: Map<string, Stream>;
|
|
7
|
+
stash: Stash;
|
|
5
8
|
};
|
|
6
9
|
logs: {
|
|
7
10
|
info: (m: string, att?: object) => void;
|
|
11
|
+
error: (m: string, att?: object) => void;
|
|
12
|
+
};
|
|
13
|
+
configuration: {
|
|
14
|
+
maxlen: number;
|
|
15
|
+
expire: number;
|
|
8
16
|
};
|
|
9
17
|
}
|
|
10
18
|
export interface PushInput {
|
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.effect = void 0;
|
|
4
4
|
async function effect({ key, event, data }, context) {
|
|
5
5
|
context.state.streams.get(key)?.push({ event, data });
|
|
6
|
+
void context.state.stash.push(key, event, data).then((token) => {
|
|
7
|
+
if (token instanceof Error)
|
|
8
|
+
context.logs.error('Failed to push to stash', { key, error: token });
|
|
9
|
+
else
|
|
10
|
+
context.state.streams.get(key)?.push({ event: 'token', data: token });
|
|
11
|
+
});
|
|
6
12
|
}
|
|
7
13
|
exports.effect = effect;
|
|
8
14
|
//# sourceMappingURL=push.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../source/push.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,MAAM,CAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAa,EAAE,OAAgB;IAC7E,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../source/push.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,MAAM,CAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAa,EAAE,OAAgB;IAC7E,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAErD,KAAK,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7D,IAAI,KAAK,YAAY,KAAK;YACxB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;;YAEpE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;AACJ,CAAC;AATD,wBASC"}
|