@toa.io/extensions.convergence 1.0.0-alpha.320 → 1.0.0-alpha.322
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/package.json +4 -4
- package/readme.md +8 -0
- package/transpiled/Destination.d.ts +4 -0
- package/transpiled/Destination.js +8 -0
- package/transpiled/Destination.js.map +1 -1
- package/transpiled/Factory.js +1 -1
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Storage.d.ts +19 -6
- package/transpiled/Storage.js +25 -8
- package/transpiled/Storage.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/extensions.convergence",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.322",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Toa Convergence extension",
|
|
6
6
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"transpile": "tsc"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
32
|
-
"@toa.io/definitions": "1.0.0-alpha.
|
|
31
|
+
"@toa.io/core": "1.0.0-alpha.322",
|
|
32
|
+
"@toa.io/definitions": "1.0.0-alpha.322",
|
|
33
33
|
"@toa.io/generic": "1.0.0-alpha.311",
|
|
34
34
|
"@toa.io/pointer": "1.0.0-alpha.311",
|
|
35
35
|
"openspan": "1.0.0-alpha.305"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ef65352a8bd7bc0ef400fcc8cde0e19a3bb92199"
|
|
38
38
|
}
|
package/readme.md
CHANGED
|
@@ -103,6 +103,10 @@ Nothing is transactional across regions.
|
|
|
103
103
|
convergence and nothing else: the region's own events are unaffected, and neither is republished
|
|
104
104
|
because of the other.
|
|
105
105
|
|
|
106
|
+
**What the other destinations write, where each region keeps its own.** A component's
|
|
107
|
+
[regional destinations](/documentation/outbox.md#regional-destinations) — realtime's streams — are
|
|
108
|
+
written in every region a change reaches, whether its record is applied there or not.
|
|
109
|
+
|
|
106
110
|
**Changes only.** Convergence carries what happens after it is on. Seeding a new region is a
|
|
107
111
|
database copy, made before it serves.
|
|
108
112
|
|
|
@@ -129,6 +133,10 @@ go is logged rather than dropped in silence.
|
|
|
129
133
|
value, and the record that arrives second cannot be stored at all. It is logged and dropped;
|
|
130
134
|
redelivery would not help.
|
|
131
135
|
|
|
136
|
+
**[`once`](/documentation/inbox.md) holds within a region.** A duplicate is answered with the
|
|
137
|
+
first reply where it arrives in the region that made the call, and made again where it arrives in
|
|
138
|
+
another, so a caller that retries against a different region is not deduplicated.
|
|
139
|
+
|
|
132
140
|
## What a record carries
|
|
133
141
|
|
|
134
142
|
[`REGION`](/documentation/component/declaration.md#entity) is which region wrote a record, as
|
|
@@ -8,6 +8,8 @@ import type { bindings, outbox } from '@toa.io/core/types';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class Destination extends Connector implements outbox.Destination {
|
|
10
10
|
readonly name = "convergence";
|
|
11
|
+
readonly carries = true;
|
|
12
|
+
regional?: outbox.Regional;
|
|
11
13
|
private readonly label;
|
|
12
14
|
private readonly resolve;
|
|
13
15
|
private readonly span;
|
|
@@ -30,4 +32,6 @@ export interface Message {
|
|
|
30
32
|
record: object;
|
|
31
33
|
/** W3C traceparent, so the far side continues the trace of the write that caused it */
|
|
32
34
|
trace?: string;
|
|
35
|
+
/** what the regional destinations of the component exported for the change, by their names */
|
|
36
|
+
carried?: Record<string, unknown>;
|
|
33
37
|
}
|
|
@@ -8,6 +8,8 @@ import { CHANNEL } from '@toa.io/definitions/extensions.convergence';
|
|
|
8
8
|
*/
|
|
9
9
|
export class Destination extends Connector {
|
|
10
10
|
name = CHANNEL;
|
|
11
|
+
carries = true;
|
|
12
|
+
regional;
|
|
11
13
|
label;
|
|
12
14
|
resolve;
|
|
13
15
|
span;
|
|
@@ -45,10 +47,16 @@ export class Destination extends Connector {
|
|
|
45
47
|
* `row.trail` is deliberately not carried. The far side writes the record through the
|
|
46
48
|
* storage rather than through an operation, so it makes no call and publishes no event —
|
|
47
49
|
* there is no chain there to continue, and nothing to refuse.
|
|
50
|
+
*
|
|
51
|
+
* What the regional destinations would write is carried as they exported it: the far side
|
|
52
|
+
* hands it back to theirs, and nothing here reads it.
|
|
48
53
|
*/
|
|
49
54
|
const message = { record: row.event.state };
|
|
50
55
|
if (context !== undefined)
|
|
51
56
|
message.trace = encode(context);
|
|
57
|
+
const carried = await this.regional?.export(row);
|
|
58
|
+
if (carried !== undefined)
|
|
59
|
+
message.carried = carried;
|
|
52
60
|
await this.outbound.send(this.label, message);
|
|
53
61
|
});
|
|
54
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Destination.js","sourceRoot":"","sources":["../source/Destination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAA;AAIpE;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxB,IAAI,GAAG,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Destination.js","sourceRoot":"","sources":["../source/Destination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAA;AAIpE;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxB,IAAI,GAAG,OAAO,CAAA;IACd,OAAO,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAkB;IAEhB,KAAK,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AC3B,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAM;QAEzB,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;QAEpC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;QAE7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
package/transpiled/Factory.js
CHANGED
|
@@ -53,7 +53,7 @@ export class Factory {
|
|
|
53
53
|
});
|
|
54
54
|
return storage;
|
|
55
55
|
}
|
|
56
|
-
return new Converging(storage, locator, async (sink) => this.host.inbound(this.binding(), CHANNEL, this.uris(), locator.id, sink));
|
|
56
|
+
return new Converging(storage, locator, async (sink) => this.host.inbound(this.binding(), CHANNEL, this.uris(), locator.id, sink), () => destination.regional);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* One publisher per process — and per build of its tree. A communication that went down with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,EAAE,EACH,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAIzC;;;;GAIG;AACH,MAAM,OAAO,OAAO;IACD,IAAI,CAAiB;IAEtC,6EAA6E;IACrE,QAAQ,CAAwC;IAExD;;;;;OAKG;IACc,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAA;IAE9D,YAAmB,IAAqB;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA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ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { Connector } from '@toa.io/core';
|
|
2
2
|
import type { Readable } from 'node:stream';
|
|
3
3
|
import type { Connector as Link, Locator } from '@toa.io/core';
|
|
4
|
-
import type { bindings, outbox, storages } from '@toa.io/core/types';
|
|
4
|
+
import type { bindings, inbox, outbox, storages } from '@toa.io/core/types';
|
|
5
|
+
/**
|
|
6
|
+
* Every member of `T`, the optional ones included, each as `T` types it. A member of the storage
|
|
7
|
+
* this does not delegate is lost to every component that converges, and nothing says so — an
|
|
8
|
+
* optional one is not required by `implements storages.Storage`, and the inbox went missing that
|
|
9
|
+
* way.
|
|
10
|
+
*/
|
|
11
|
+
type Whole<T> = {
|
|
12
|
+
[K in keyof Required<T>]: T[K];
|
|
13
|
+
};
|
|
5
14
|
/**
|
|
6
15
|
* A record from another region is written as it stands: its version, its timestamps, its
|
|
7
16
|
* region. That is neither a transition nor an assignment — it is not this region's version to
|
|
@@ -11,13 +20,14 @@ import type { bindings, outbox, storages } from '@toa.io/core/types';
|
|
|
11
20
|
* Everything else it delegates. It decorates the storage because that is where a handle to one
|
|
12
21
|
* is, not because it changes anything a component reads or writes.
|
|
13
22
|
*/
|
|
14
|
-
export declare class Converging extends Connector implements storages.Storage
|
|
23
|
+
export declare class Converging extends Connector implements Whole<storages.Storage>, bindings.Inbound {
|
|
15
24
|
private readonly storage;
|
|
16
25
|
private readonly locator;
|
|
17
26
|
private readonly subscribe;
|
|
27
|
+
private readonly regional;
|
|
18
28
|
private readonly delivery;
|
|
19
29
|
private readonly processing;
|
|
20
|
-
constructor(storage: storages.Storage, locator: Locator, connect: (sink: bindings.Inbound) => Promise<Link
|
|
30
|
+
constructor(storage: storages.Storage, locator: Locator, connect: (sink: bindings.Inbound) => Promise<Link>, regional?: () => outbox.Regional | undefined);
|
|
21
31
|
/**
|
|
22
32
|
* There is no counter to increment here, so the outcome is on the span: without it,
|
|
23
33
|
* convergence dropping a duplicate and convergence dropping everything look exactly alike.
|
|
@@ -26,14 +36,17 @@ export declare class Converging extends Connector implements storages.Storage, b
|
|
|
26
36
|
protected open(): Promise<void>;
|
|
27
37
|
get raw(): unknown;
|
|
28
38
|
get outbox(): storages.Storage['outbox'];
|
|
39
|
+
get inbox(): storages.Storage['inbox'];
|
|
40
|
+
get claims(): boolean | undefined;
|
|
29
41
|
get migrates(): boolean | undefined;
|
|
30
42
|
get converges(): boolean | undefined;
|
|
31
43
|
get(query: storages.Query): Promise<storages.Record | null>;
|
|
32
44
|
find(query: storages.Query): Promise<storages.Record[]>;
|
|
33
45
|
stream(query?: storages.Query): Promise<Readable>;
|
|
34
|
-
store(record: storages.Record, row?: outbox.Row): Promise<boolean>;
|
|
46
|
+
store(record: storages.Record, row?: outbox.Row, call?: inbox.Call): Promise<boolean>;
|
|
35
47
|
massStore(records: storages.Record[], rows?: outbox.Row[]): Promise<boolean>;
|
|
36
|
-
upsert(query: storages.Query, changeset: object, row?: outbox.Row): Promise<storages.Record | null>;
|
|
37
|
-
ensure(query: storages.Query | undefined, properties: object, record: storages.Record, row?: outbox.Row): Promise<storages.Record>;
|
|
48
|
+
upsert(query: storages.Query, changeset: object, row?: outbox.Row, call?: inbox.Call): Promise<storages.Record | null>;
|
|
49
|
+
ensure(query: storages.Query | undefined, properties: object, record: storages.Record, row?: outbox.Row, call?: inbox.Call): Promise<storages.Record>;
|
|
38
50
|
converge(record: storages.Record): Promise<boolean>;
|
|
39
51
|
}
|
|
52
|
+
export {};
|
package/transpiled/Storage.js
CHANGED
|
@@ -16,13 +16,16 @@ export class Converging extends Connector {
|
|
|
16
16
|
storage;
|
|
17
17
|
locator;
|
|
18
18
|
subscribe;
|
|
19
|
+
regional;
|
|
19
20
|
delivery;
|
|
20
21
|
processing;
|
|
21
|
-
|
|
22
|
+
// eslint-disable-next-line max-params
|
|
23
|
+
constructor(storage, locator, connect, regional = () => undefined) {
|
|
22
24
|
super();
|
|
23
25
|
this.storage = storage;
|
|
24
26
|
this.locator = locator;
|
|
25
27
|
this.subscribe = connect;
|
|
28
|
+
this.regional = regional;
|
|
26
29
|
// what it decorates opens before it and closes after it, so the storage is whole while a
|
|
27
30
|
// delivery is still draining
|
|
28
31
|
this.depends(storage);
|
|
@@ -44,7 +47,7 @@ export class Converging extends Connector {
|
|
|
44
47
|
* convergence dropping a duplicate and convergence dropping everything look exactly alike.
|
|
45
48
|
*/
|
|
46
49
|
async accept(message) {
|
|
47
|
-
const { record, trace } = message;
|
|
50
|
+
const { record, trace, carried } = message;
|
|
48
51
|
/*
|
|
49
52
|
* A record carrying this region's own rank cannot have come from anywhere: a region is
|
|
50
53
|
* not bound to what it publishes, and it republishes nothing it converges, so the rank on a
|
|
@@ -65,6 +68,13 @@ export class Converging extends Connector {
|
|
|
65
68
|
component: this.locator.id,
|
|
66
69
|
outcome: applied ? 'applied' : 'stale'
|
|
67
70
|
});
|
|
71
|
+
/*
|
|
72
|
+
* Whatever became of the record: what the change wrote beside it happened where it
|
|
73
|
+
* was committed, whichever record wins. What fails here fails the delivery, which
|
|
74
|
+
* converges the record again to no effect and imports again.
|
|
75
|
+
*/
|
|
76
|
+
if (carried !== undefined)
|
|
77
|
+
await this.regional()?.import(carried);
|
|
68
78
|
}));
|
|
69
79
|
if (remote === null)
|
|
70
80
|
await task();
|
|
@@ -90,6 +100,12 @@ export class Converging extends Connector {
|
|
|
90
100
|
get outbox() {
|
|
91
101
|
return this.storage.outbox;
|
|
92
102
|
}
|
|
103
|
+
get inbox() {
|
|
104
|
+
return this.storage.inbox;
|
|
105
|
+
}
|
|
106
|
+
get claims() {
|
|
107
|
+
return this.storage.claims;
|
|
108
|
+
}
|
|
93
109
|
get migrates() {
|
|
94
110
|
return this.storage.migrates;
|
|
95
111
|
}
|
|
@@ -105,18 +121,19 @@ export class Converging extends Connector {
|
|
|
105
121
|
async stream(query) {
|
|
106
122
|
return this.storage.stream(query);
|
|
107
123
|
}
|
|
108
|
-
async store(record, row) {
|
|
109
|
-
return this.storage.store(record, row);
|
|
124
|
+
async store(record, row, call) {
|
|
125
|
+
return this.storage.store(record, row, call);
|
|
110
126
|
}
|
|
111
127
|
async massStore(records, rows) {
|
|
112
128
|
return this.storage.massStore(records, rows);
|
|
113
129
|
}
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
// eslint-disable-next-line max-params
|
|
131
|
+
async upsert(query, changeset, row, call) {
|
|
132
|
+
return this.storage.upsert(query, changeset, row, call);
|
|
116
133
|
}
|
|
117
134
|
// eslint-disable-next-line max-params
|
|
118
|
-
async ensure(query, properties, record, row) {
|
|
119
|
-
return this.storage.ensure(query, properties, record, row);
|
|
135
|
+
async ensure(query, properties, record, row, call) {
|
|
136
|
+
return this.storage.ensure(query, properties, record, row, call);
|
|
120
137
|
}
|
|
121
138
|
async converge(record) {
|
|
122
139
|
return this.storage.converge(record);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../source/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAoB,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAA;AAKpE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../source/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAoB,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAA;AAKpE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAU1C;;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