@iwentsourcing/core 0.1.0 → 0.2.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/aggregation/aggregation-declaration.d.ts +27 -27
- package/dist/authentication/public-auth-providers.js.map +1 -1
- package/dist/event-store/create-file-event-store.d.ts +1 -1
- package/dist/example/todo-example.d.ts +6 -6
- package/dist/management/access/access-events.d.ts +104 -104
- package/dist/management/access/access-state.d.ts +269 -269
- package/dist/management/access/access-stream.d.ts +286 -286
- package/dist/management/authentication/authentication-state.d.ts +21 -21
- package/dist/management/authentication/authentication-stream.d.ts +66 -66
- package/dist/management/permission/permission-aggregation.d.ts +101 -101
- package/dist/management/permission/permission-aggregation.test.js +0 -1
- package/dist/management/permission/permission-aggregation.test.js.map +1 -1
- package/dist/management/permission-error-schema.d.ts +29 -29
- package/dist/management/registry/registry-events.d.ts +186 -186
- package/dist/management/registry/registry-state.d.ts +55 -55
- package/dist/management/registry/registry-stream.d.ts +284 -284
- package/dist/management/state-read-policy.js.map +1 -1
- package/dist/management/system/iwentsourcing-realm.d.ts +106 -106
- package/dist/runtime/host-result-builder.d.ts +13 -13
- package/dist/runtime/permission-grant-schema.d.ts +7 -7
- package/dist/runtime/runtime-result.d.ts +26 -26
- package/dist/sequencer/create-sequencer-storage.d.ts +4 -4
- package/dist/sequencer/create-state-processor.d.ts +4 -4
- package/dist/sequencer/sequence-topic.d.ts +1 -1
- package/dist/stream/stream-declaration.d.ts +34 -34
- package/dist/tsbuild.info +1 -1
- package/dist/utils/combine-abort-signal.js.map +1 -1
- package/dist/worker/create-stream-worker.d.ts +2 -2
- package/package.json +1 -1
- package/dist/lock/exclusive-lock.d.ts +0 -4
- package/dist/lock/exclusive-lock.js +0 -8
- package/dist/lock/exclusive-lock.js.map +0 -1
- package/dist/management/managed-permission-denied-error.d.ts +0 -50
- package/dist/management/managed-permission-denied-error.js +0 -26
- package/dist/management/managed-permission-denied-error.js.map +0 -1
- package/dist/processing/create-event-processor.d.ts +0 -23
- package/dist/processing/create-event-processor.js +0 -133
- package/dist/processing/create-event-processor.js.map +0 -1
- package/dist/processing/create-event-processor.test.d.ts +0 -1
- package/dist/processing/create-event-processor.test.js +0 -218
- package/dist/processing/create-event-processor.test.js.map +0 -1
- package/dist/processing/event-processing-topic.d.ts +0 -5
- package/dist/processing/event-processing-topic.js +0 -13
- package/dist/processing/event-processing-topic.js.map +0 -1
- package/dist/processing/select-event-shard.d.ts +0 -1
- package/dist/processing/select-event-shard.js +0 -14
- package/dist/processing/select-event-shard.js.map +0 -1
- package/dist/processing/sequencer-cache-key.d.ts +0 -2
- package/dist/processing/sequencer-cache-key.js +0 -13
- package/dist/processing/sequencer-cache-key.js.map +0 -1
- package/dist/tmp-typetest.d.ts +0 -1
- package/dist/tmp-typetest.js +0 -3
- package/dist/tmp-typetest.js.map +0 -1
- package/dist/tracer/create-noop-telemetry.d.ts +0 -2
- package/dist/tracer/create-noop-telemetry.js +0 -22
- package/dist/tracer/create-noop-telemetry.js.map +0 -1
- package/dist/tracer/create-tracer.d.ts +0 -2
- package/dist/tracer/create-tracer.js +0 -15
- package/dist/tracer/create-tracer.js.map +0 -1
- package/dist/utils/lru-cache.d.ts +0 -11
- package/dist/utils/lru-cache.js +0 -44
- package/dist/utils/lru-cache.js.map +0 -1
- package/dist/worker/create-stream-wroker.test.d.ts +0 -0
- package/dist/worker/create-stream-wroker.test.js +0 -2
- package/dist/worker/create-stream-wroker.test.js.map +0 -1
- package/dist/worker/process-pending-events.d.ts +0 -20
- package/dist/worker/process-pending-events.js +0 -106
- package/dist/worker/process-pending-events.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combine-abort-signal.js","sourceRoot":"","sources":["../../src/utils/combine-abort-signal.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,
|
|
1
|
+
{"version":3,"file":"combine-abort-signal.js","sourceRoot":"","sources":["../../src/utils/combine-abort-signal.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAChC,KAAkB,EAClB,MAAmB;IAEnB,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IAEnC,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACrD,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,GAAG,EAAE;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACrD,CAAC,CAAC;IAEF,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
|
|
@@ -11,11 +11,11 @@ export interface WorkerOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const streamWorkerProcessTopic: Readonly<import("../queue/topic-definition.js").TopicDefinition<["tenant", "realm", "pattern", "version"], import("../typing/object-type-description.js").ObjectTypeDescription<{
|
|
13
13
|
event: string;
|
|
14
|
+
eventId: string;
|
|
15
|
+
storedAt: Date;
|
|
14
16
|
streamArgs: {
|
|
15
17
|
[key: string]: string;
|
|
16
18
|
};
|
|
17
|
-
eventId: string;
|
|
18
|
-
storedAt: Date;
|
|
19
19
|
}>>>;
|
|
20
20
|
export declare const streamWorkerAttachedTopic: Readonly<import("../queue/topic-definition.js").TopicDefinition<["tenant", "realm", "pattern", "version"], import("../typing/object-type-description.js").ObjectTypeDescription<{
|
|
21
21
|
event: string;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exclusive-lock.js","sourceRoot":"","sources":["../../src/lock/exclusive-lock.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,YAAY,CAAC,KAAK,EAAE,EAAE;YACpB,OAAO,EAAE,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { SequencerPartition } from '../sequencer/sequencer-partition.js';
|
|
2
|
-
import type { UserContext } from './user-context.js';
|
|
3
|
-
export type ManagedPermissionDeniedDetail = {
|
|
4
|
-
kind: 'state-read';
|
|
5
|
-
stateName: string;
|
|
6
|
-
permissionPresent: boolean;
|
|
7
|
-
permissionRead: boolean;
|
|
8
|
-
} | {
|
|
9
|
-
kind: 'event-write';
|
|
10
|
-
eventName: string;
|
|
11
|
-
permissionPresent: boolean;
|
|
12
|
-
permissionWrite: boolean;
|
|
13
|
-
} | {
|
|
14
|
-
kind: 'event-read';
|
|
15
|
-
eventName: string;
|
|
16
|
-
storedEventId: string;
|
|
17
|
-
permissionPresent: boolean;
|
|
18
|
-
permissionRead: boolean;
|
|
19
|
-
} | {
|
|
20
|
-
kind: 'state-read-policy';
|
|
21
|
-
stateName: string;
|
|
22
|
-
terminal: string;
|
|
23
|
-
indexName?: string;
|
|
24
|
-
indexBindings?: Record<string, string>;
|
|
25
|
-
};
|
|
26
|
-
export type ManagedPermissionDeniedPayload = {
|
|
27
|
-
partition: SequencerPartition;
|
|
28
|
-
context: {
|
|
29
|
-
authId: string;
|
|
30
|
-
name: string;
|
|
31
|
-
args: Record<string, string>;
|
|
32
|
-
auth: {
|
|
33
|
-
sub: string;
|
|
34
|
-
aud: string;
|
|
35
|
-
iss: string;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
detail: ManagedPermissionDeniedDetail;
|
|
39
|
-
};
|
|
40
|
-
export declare function managedPermissionDeniedPayload(error: ManagedPermissionDeniedError): ManagedPermissionDeniedPayload;
|
|
41
|
-
export declare class ManagedPermissionDeniedError extends Error {
|
|
42
|
-
readonly context: UserContext;
|
|
43
|
-
readonly partition: SequencerPartition;
|
|
44
|
-
readonly detail: ManagedPermissionDeniedDetail;
|
|
45
|
-
constructor(opts: {
|
|
46
|
-
context: UserContext;
|
|
47
|
-
partition: SequencerPartition;
|
|
48
|
-
detail: ManagedPermissionDeniedDetail;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export function managedPermissionDeniedPayload(error) {
|
|
2
|
-
return {
|
|
3
|
-
partition: { ...error.partition },
|
|
4
|
-
context: {
|
|
5
|
-
authId: error.context.authId,
|
|
6
|
-
name: error.context.name,
|
|
7
|
-
args: { ...error.context.args },
|
|
8
|
-
auth: { ...error.context.auth },
|
|
9
|
-
},
|
|
10
|
-
detail: error.detail,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export class ManagedPermissionDeniedError extends Error {
|
|
14
|
-
context;
|
|
15
|
-
partition;
|
|
16
|
-
detail;
|
|
17
|
-
constructor(opts) {
|
|
18
|
-
super('no permission');
|
|
19
|
-
this.name = 'ManagedPermissionDeniedError';
|
|
20
|
-
this.context = opts.context;
|
|
21
|
-
this.partition = opts.partition;
|
|
22
|
-
this.detail = opts.detail;
|
|
23
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=managed-permission-denied-error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-permission-denied-error.js","sourceRoot":"","sources":["../../src/management/managed-permission-denied-error.ts"],"names":[],"mappings":"AA0CA,MAAM,UAAU,8BAA8B,CAC5C,KAAmC;IAEnC,OAAO;QACL,SAAS,EAAE,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE;QACjC,OAAO,EAAE;YACP,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM;YAC5B,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;YACxB,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;YAC/B,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;SAChC;QACD,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAC5C,OAAO,CAAc;IACrB,SAAS,CAAqB;IAC9B,MAAM,CAAgC;IAE/C,YAAY,IAIX;QACC,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BootstrapperPiece } from '../runner/bootstrapper.js';
|
|
2
|
-
import { RuntimeOptions } from '../management/runtime-options.js';
|
|
3
|
-
import { Systems } from '../management/system/systems.js';
|
|
4
|
-
import { Subscription } from '../queue/subscription.js';
|
|
5
|
-
import { eventProcessingTopic } from './event-processing-topic.js';
|
|
6
|
-
import { Registry } from '../registry/registry.js';
|
|
7
|
-
export interface EventProcessorOptions {
|
|
8
|
-
runtime: RuntimeOptions;
|
|
9
|
-
system: Systems;
|
|
10
|
-
registry: Registry;
|
|
11
|
-
parallelism?: number;
|
|
12
|
-
shard?: number;
|
|
13
|
-
shardCount?: number;
|
|
14
|
-
subscriptionName?: string;
|
|
15
|
-
eventProcessing?: {
|
|
16
|
-
sequencerCacheSize?: number;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
interface EventProcessorInit {
|
|
20
|
-
subscription: Subscription<typeof eventProcessingTopic>;
|
|
21
|
-
}
|
|
22
|
-
export declare function createEventProcessor(opts: EventProcessorOptions): BootstrapperPiece<EventProcessorInit>;
|
|
23
|
-
export {};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '../logger/logger.js';
|
|
2
|
-
import { eventProcessingTopic } from './event-processing-topic.js';
|
|
3
|
-
import { getManagedAggregationSequencers } from '../worker/get-managed-stream-sequencers.js';
|
|
4
|
-
import { getManagedStreamSequencers } from '../worker/get-managed-stream-sequencers.js';
|
|
5
|
-
import { getErrorMessage } from '../runtime/get-error-message.js';
|
|
6
|
-
import { LruCache } from '../utils/lru-cache.js';
|
|
7
|
-
const logger = createLogger('event-processor');
|
|
8
|
-
export function createEventProcessor(opts) {
|
|
9
|
-
const registry = opts.registry;
|
|
10
|
-
const tracer = opts.runtime.telemetry.createTracer('event-processor');
|
|
11
|
-
const cacheSize = opts.runtime.eventProcessing?.sequencerCacheSize ??
|
|
12
|
-
opts.eventProcessing?.sequencerCacheSize ??
|
|
13
|
-
200;
|
|
14
|
-
const streamSequencers = new LruCache(cacheSize);
|
|
15
|
-
const aggregationSequencers = new LruCache(cacheSize);
|
|
16
|
-
const shardFilter = opts.shard === undefined
|
|
17
|
-
? undefined
|
|
18
|
-
: {
|
|
19
|
-
shard: String(opts.shard),
|
|
20
|
-
};
|
|
21
|
-
const subscriptionName = opts.subscriptionName ??
|
|
22
|
-
`event-processor-${opts.shard !== undefined ? opts.shard : 'all'}`;
|
|
23
|
-
return {
|
|
24
|
-
async initialize(signal) {
|
|
25
|
-
await opts.runtime.queue.createTopic(eventProcessingTopic, {
|
|
26
|
-
signal,
|
|
27
|
-
});
|
|
28
|
-
const subscription = await opts.runtime.queue.createSubscription(eventProcessingTopic, subscriptionName, {
|
|
29
|
-
filter: shardFilter ?? {},
|
|
30
|
-
autoRemove: false,
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
subscription,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
async run(init, signal) {
|
|
37
|
-
const parallelism = opts.parallelism ??
|
|
38
|
-
opts.runtime.eventProcessing?.parallelism ??
|
|
39
|
-
4;
|
|
40
|
-
const limit = Math.max(1, parallelism);
|
|
41
|
-
const inFlight = new Set();
|
|
42
|
-
const cleanup = async () => {
|
|
43
|
-
try {
|
|
44
|
-
await init.subscription.remove(signal);
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
logger.debug('cleanup subscription failed', {
|
|
48
|
-
error: getErrorMessage(err),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
signal.addEventListener('abort', cleanup, { once: true });
|
|
53
|
-
try {
|
|
54
|
-
for await (const message of init.subscription.consume({ signal })) {
|
|
55
|
-
if (signal.aborted) {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
const task = handleMessage(message, signal).finally(() => {
|
|
59
|
-
inFlight.delete(task);
|
|
60
|
-
});
|
|
61
|
-
inFlight.add(task);
|
|
62
|
-
if (inFlight.size >= limit) {
|
|
63
|
-
await Promise.race(inFlight);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
await Promise.allSettled(inFlight);
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
await cleanup();
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
async function handleMessage(message, signal) {
|
|
74
|
-
await tracer.createSpan('process.message', {
|
|
75
|
-
attributes: {
|
|
76
|
-
event: message.data.event,
|
|
77
|
-
eventId: message.data.eventId,
|
|
78
|
-
shard: message.attributes.shard,
|
|
79
|
-
},
|
|
80
|
-
}, async () => {
|
|
81
|
-
try {
|
|
82
|
-
await processSequencers(message, signal);
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
logger.error(getErrorMessage(err));
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
await message.ack();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
async function processSequencers(message, signal) {
|
|
93
|
-
const sequencers = [];
|
|
94
|
-
for await (const sequencer of getManagedStreamSequencers({ registry, runtime: opts.runtime, system: opts.system }, message.attributes.tenant, message.attributes.realm, message.attributes.pattern, message.attributes.version, message.data.event, signal, streamSequencers)) {
|
|
95
|
-
sequencers.push(sequencer);
|
|
96
|
-
}
|
|
97
|
-
for await (const sequencer of getManagedAggregationSequencers({ registry, runtime: opts.runtime, system: opts.system }, message.attributes.tenant, message.attributes.realm, message.attributes.pattern, message.attributes.version, message.data.event, signal, aggregationSequencers)) {
|
|
98
|
-
sequencers.push(sequencer);
|
|
99
|
-
}
|
|
100
|
-
await Promise.all(sequencers.map((sequencer) => processSingleSequencer(sequencer, {
|
|
101
|
-
id: message.data.eventId,
|
|
102
|
-
storedAt: message.data.storedAt,
|
|
103
|
-
event: message.data.event,
|
|
104
|
-
}, opts.runtime.telemetry, signal)));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function processSingleSequencer(sequencer, event, telemetry, signal) {
|
|
108
|
-
const tracer = telemetry.createTracer('event-processor');
|
|
109
|
-
await tracer.createSpan('process.sequencer', {
|
|
110
|
-
attributes: {
|
|
111
|
-
stream: sequencer.partition.name,
|
|
112
|
-
realm: sequencer.partition.realm,
|
|
113
|
-
pattern: sequencer.partition.pattern,
|
|
114
|
-
version: sequencer.partition.version,
|
|
115
|
-
},
|
|
116
|
-
}, async () => {
|
|
117
|
-
try {
|
|
118
|
-
for await (const result of sequencer.attach({ id: event.id }, signal)) {
|
|
119
|
-
logger.debug('event processed', {
|
|
120
|
-
id: event.id,
|
|
121
|
-
stream: sequencer.partition.name,
|
|
122
|
-
success: result.success,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
if (!signal.aborted) {
|
|
128
|
-
logger.error(getErrorMessage(err));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=create-event-processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-event-processor.js","sourceRoot":"","sources":["../../src/processing/create-event-processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAGxF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAmB/C,MAAM,UAAU,oBAAoB,CAClC,IAA2B;IAE3B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACtE,MAAM,SAAS,GACb,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,kBAAkB;QAChD,IAAI,CAAC,eAAe,EAAE,kBAAkB;QACxC,GAAG,CAAC;IACN,MAAM,gBAAgB,GAAG,IAAI,QAAQ,CAA4B,SAAS,CAAC,CAAC;IAC5E,MAAM,qBAAqB,GAAG,IAAI,QAAQ,CACxC,SAAS,CACV,CAAC;IAEF,MAAM,WAAW,GACf,IAAI,CAAC,KAAK,KAAK,SAAS;QACtB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC;YACE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SAC1B,CAAC;IAER,MAAM,gBAAgB,GACpB,IAAI,CAAC,gBAAgB;QACrB,mBAAmB,IAAI,CAAC,KAAK,KAAK,SA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
import { createEventProcessor } from './create-event-processor.js';
|
|
4
|
-
import { createTestRuntime } from '../testing/create-test-case.js';
|
|
5
|
-
import { defineState } from '../storage/define-state.js';
|
|
6
|
-
import { declareState } from '../storage/declare-state.js';
|
|
7
|
-
import { string } from '../typing/string.js';
|
|
8
|
-
import { number } from '../typing/number.js';
|
|
9
|
-
import { defineEvents } from '../stream/define-events.js';
|
|
10
|
-
import { declareEvent } from '../storage/declare-event.js';
|
|
11
|
-
import { createHostRuntime } from '../runtime/create-host-runtime.js';
|
|
12
|
-
import { mapFromStateDeclarations } from '../management/map-from-state-declarations.js';
|
|
13
|
-
import { mapFromEventDeclarations } from '../management/map-from-event-declarations.js';
|
|
14
|
-
import { createStreamInstanceEventStore } from '../event-store/create-stream-instance-event-store.js';
|
|
15
|
-
import { mapToStateDefinitions } from '../management/map-from-state-declarations.js';
|
|
16
|
-
import { createSequencerStorage } from '../sequencer/create-sequencer-storage.js';
|
|
17
|
-
import { selectEventShard } from './select-event-shard.js';
|
|
18
|
-
function createStubSystem() {
|
|
19
|
-
const emptyStream = {
|
|
20
|
-
snapshot: () => ({
|
|
21
|
-
range: async function* () {
|
|
22
|
-
return;
|
|
23
|
-
},
|
|
24
|
-
index() {
|
|
25
|
-
return this;
|
|
26
|
-
},
|
|
27
|
-
filter() {
|
|
28
|
-
return this;
|
|
29
|
-
},
|
|
30
|
-
get() {
|
|
31
|
-
return Promise.resolve(null);
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
};
|
|
35
|
-
const emptyAggregate = {
|
|
36
|
-
snapshot: () => ({
|
|
37
|
-
range: async function* () {
|
|
38
|
-
return;
|
|
39
|
-
},
|
|
40
|
-
get() {
|
|
41
|
-
return Promise.resolve(null);
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
access() {
|
|
47
|
-
return emptyStream;
|
|
48
|
-
},
|
|
49
|
-
registry() {
|
|
50
|
-
return emptyStream;
|
|
51
|
-
},
|
|
52
|
-
auth() {
|
|
53
|
-
return emptyStream;
|
|
54
|
-
},
|
|
55
|
-
permission() {
|
|
56
|
-
return emptyAggregate;
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function createCounterStreamRegistration() {
|
|
61
|
-
const state = defineState([
|
|
62
|
-
declareState('counters', {
|
|
63
|
-
id: string(),
|
|
64
|
-
value: number(),
|
|
65
|
-
}, ['id']),
|
|
66
|
-
]);
|
|
67
|
-
const events = defineEvents([
|
|
68
|
-
declareEvent('increment', {
|
|
69
|
-
id: string(),
|
|
70
|
-
amount: number(),
|
|
71
|
-
}),
|
|
72
|
-
]);
|
|
73
|
-
const registration = {
|
|
74
|
-
identifier: {
|
|
75
|
-
tenant: 'tenant',
|
|
76
|
-
realm: 'realm',
|
|
77
|
-
pattern: 'counter',
|
|
78
|
-
version: 'v1',
|
|
79
|
-
},
|
|
80
|
-
state: mapFromStateDeclarations(state),
|
|
81
|
-
events: mapFromEventDeclarations(events),
|
|
82
|
-
outputs: {},
|
|
83
|
-
runtime: createHostRuntime(events, {
|
|
84
|
-
increment: async (evt, ctx) => {
|
|
85
|
-
const existing = (await ctx.snapshot('counters').get({ id: evt.id }, { signal: ctx.signal })) ?? null;
|
|
86
|
-
if (!existing) {
|
|
87
|
-
await ctx.state('counters').insert({
|
|
88
|
-
id: evt.id,
|
|
89
|
-
value: evt.amount,
|
|
90
|
-
}, { signal: ctx.signal });
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
await ctx.state('counters').patch({
|
|
94
|
-
id: evt.id,
|
|
95
|
-
value: existing.data.value + evt.amount,
|
|
96
|
-
}, { signal: ctx.signal });
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
}, {}),
|
|
100
|
-
auth: { allowAnonymous: true },
|
|
101
|
-
};
|
|
102
|
-
const partition = {
|
|
103
|
-
tenant: 'tenant',
|
|
104
|
-
realm: 'realm',
|
|
105
|
-
pattern: 'counter',
|
|
106
|
-
version: 'v1',
|
|
107
|
-
name: 'counter',
|
|
108
|
-
run: 1,
|
|
109
|
-
};
|
|
110
|
-
return { registration, partition };
|
|
111
|
-
}
|
|
112
|
-
function createStubRegistry(registration) {
|
|
113
|
-
return {
|
|
114
|
-
async getStream(params) {
|
|
115
|
-
if (params.tenant === registration.identifier.tenant &&
|
|
116
|
-
params.realm === registration.identifier.realm &&
|
|
117
|
-
params.pattern === registration.identifier.pattern &&
|
|
118
|
-
params.version === registration.identifier.version) {
|
|
119
|
-
return registration;
|
|
120
|
-
}
|
|
121
|
-
return null;
|
|
122
|
-
},
|
|
123
|
-
async getAggregation() {
|
|
124
|
-
return null;
|
|
125
|
-
},
|
|
126
|
-
async getAuth() {
|
|
127
|
-
return {};
|
|
128
|
-
},
|
|
129
|
-
async *getAffectedAggregations() {
|
|
130
|
-
return;
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
async function readCounterValue(opts) {
|
|
135
|
-
const storage = createSequencerStorage({
|
|
136
|
-
state: mapToStateDefinitions(mapFromStateDeclarations(defineState([
|
|
137
|
-
declareState('counters', {
|
|
138
|
-
id: string(),
|
|
139
|
-
value: number(),
|
|
140
|
-
}, ['id']),
|
|
141
|
-
]))),
|
|
142
|
-
partition: opts.partition,
|
|
143
|
-
partitionBuilder: opts.runtime.partitionBuilder,
|
|
144
|
-
}, opts.signal);
|
|
145
|
-
const counter = await storage
|
|
146
|
-
.storage('state')
|
|
147
|
-
.snapshot('counters')
|
|
148
|
-
.get({ id: 'id-0' }, { signal: opts.signal });
|
|
149
|
-
return counter?.data.value ?? 0;
|
|
150
|
-
}
|
|
151
|
-
describe('create-event-processor', () => {
|
|
152
|
-
it('processes events and mutates state', async (test) => {
|
|
153
|
-
const runCtrl = new AbortController();
|
|
154
|
-
test.signal.addEventListener('abort', () => runCtrl.abort());
|
|
155
|
-
const runtime = createTestRuntime(runCtrl.signal);
|
|
156
|
-
const { registration, partition } = createCounterStreamRegistration();
|
|
157
|
-
const registry = createStubRegistry(registration);
|
|
158
|
-
const processor = createEventProcessor({
|
|
159
|
-
runtime,
|
|
160
|
-
system: createStubSystem(),
|
|
161
|
-
registry: registry,
|
|
162
|
-
});
|
|
163
|
-
const init = await processor.initialize(runCtrl.signal);
|
|
164
|
-
const runPromise = processor.run(init, runCtrl.signal);
|
|
165
|
-
const store = createStreamInstanceEventStore({ runtime, partition, acceptCreatedAsStored: false }, runCtrl.signal);
|
|
166
|
-
await store.push('increment', { id: 'id-0', amount: 2 }, { signal: runCtrl.signal, auth: { sub: 'sub', iss: 'iss', aud: 'aud' } });
|
|
167
|
-
// small delay to allow processing
|
|
168
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
169
|
-
const value = await readCounterValue({
|
|
170
|
-
runtime,
|
|
171
|
-
partition,
|
|
172
|
-
signal: runCtrl.signal,
|
|
173
|
-
});
|
|
174
|
-
assert.equal(value, 2);
|
|
175
|
-
runCtrl.abort();
|
|
176
|
-
await runPromise;
|
|
177
|
-
});
|
|
178
|
-
it('processes events across expanded shard counts', async (test) => {
|
|
179
|
-
const runCtrl = new AbortController();
|
|
180
|
-
test.signal.addEventListener('abort', () => runCtrl.abort());
|
|
181
|
-
const runtime = createTestRuntime(runCtrl.signal);
|
|
182
|
-
runtime.eventProcessing = {
|
|
183
|
-
shardCount: 2,
|
|
184
|
-
shardCounts: [1, 2],
|
|
185
|
-
};
|
|
186
|
-
const { registration, partition } = createCounterStreamRegistration();
|
|
187
|
-
const registry = createStubRegistry(registration);
|
|
188
|
-
const processor = createEventProcessor({
|
|
189
|
-
runtime,
|
|
190
|
-
system: createStubSystem(),
|
|
191
|
-
registry: registry,
|
|
192
|
-
});
|
|
193
|
-
const init = await processor.initialize(runCtrl.signal);
|
|
194
|
-
const runPromise = processor.run(init, runCtrl.signal);
|
|
195
|
-
const store = createStreamInstanceEventStore({ runtime, partition, acceptCreatedAsStored: false }, runCtrl.signal);
|
|
196
|
-
const shardCount = runtime.eventProcessing.shardCount ?? 1;
|
|
197
|
-
let idZero = 'id-0';
|
|
198
|
-
while (selectEventShard(idZero, shardCount) !== '0') {
|
|
199
|
-
idZero = `id-0-${Math.random()}`;
|
|
200
|
-
}
|
|
201
|
-
let idOne = 'id-1';
|
|
202
|
-
while (selectEventShard(idOne, shardCount) !== '1') {
|
|
203
|
-
idOne = `id-1-${Math.random()}`;
|
|
204
|
-
}
|
|
205
|
-
await store.push('increment', { id: 'id-0', amount: 1 }, { signal: runCtrl.signal, id: idZero, auth: { sub: 'sub', iss: 'iss', aud: 'aud' } });
|
|
206
|
-
await store.push('increment', { id: 'id-0', amount: 3 }, { signal: runCtrl.signal, id: idOne, auth: { sub: 'sub', iss: 'iss', aud: 'aud' } });
|
|
207
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
208
|
-
const value = await readCounterValue({
|
|
209
|
-
runtime,
|
|
210
|
-
partition,
|
|
211
|
-
signal: runCtrl.signal,
|
|
212
|
-
});
|
|
213
|
-
assert.equal(value, 4);
|
|
214
|
-
runCtrl.abort();
|
|
215
|
-
await runPromise;
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
//# sourceMappingURL=create-event-processor.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-event-processor.test.js","sourceRoot":"","sources":["../../src/processing/create-event-processor.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MA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AM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/I,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAE9I,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAEzD,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC;YACnC,OAAO;YACP,SAAS;YACT,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEvB,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,UAAU,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const eventProcessingTopic: Readonly<import("../queue/topic-definition.js").TopicDefinition<["tenant", "realm", "pattern", "version", "shard"], import("../typing/object-type-description.js").ObjectTypeDescription<{
|
|
2
|
-
storedAt: Date;
|
|
3
|
-
eventId: string;
|
|
4
|
-
event: string;
|
|
5
|
-
}>>>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineTopic } from '../queue/define-topic.js';
|
|
2
|
-
import { object } from '../typing/object.js';
|
|
3
|
-
import { date } from '../typing/date.js';
|
|
4
|
-
import { string } from '../typing/string.js';
|
|
5
|
-
export const eventProcessingTopic = defineTopic('event.processing', {
|
|
6
|
-
attributes: ['tenant', 'realm', 'pattern', 'version', 'shard'],
|
|
7
|
-
data: object('EventProcessingUpdate', {
|
|
8
|
-
storedAt: date(),
|
|
9
|
-
eventId: string(),
|
|
10
|
-
event: string(),
|
|
11
|
-
}),
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=event-processing-topic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-processing-topic.js","sourceRoot":"","sources":["../../src/processing/event-processing-topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC,kBAAkB,EAAE;IAClE,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAU;IACvE,IAAI,EAAE,MAAM,CAAC,uBAAuB,EAAE;QACpC,QAAQ,EAAE,IAAI,EAAE;QAChB,OAAO,EAAE,MAAM,EAAE;QACjB,KAAK,EAAE,MAAM,EAAE;KAChB,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function selectEventShard(eventId: string, shardCount: number): string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { serializeObject } from '../utils/serialize-object.js';
|
|
2
|
-
export function selectEventShard(eventId, shardCount) {
|
|
3
|
-
const normalizedShardCount = Math.max(1, Math.floor(shardCount));
|
|
4
|
-
if (normalizedShardCount === 1) {
|
|
5
|
-
return '0';
|
|
6
|
-
}
|
|
7
|
-
let hash = 0;
|
|
8
|
-
const data = serializeObject(eventId);
|
|
9
|
-
for (let i = 0; i < data.length; i++) {
|
|
10
|
-
hash = (hash * 31 + data.charCodeAt(i)) >>> 0;
|
|
11
|
-
}
|
|
12
|
-
return String(hash % normalizedShardCount);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=select-event-shard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"select-event-shard.js","sourceRoot":"","sources":["../../src/processing/select-event-shard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,UAAkB;IAElB,MAAM,oBAAoB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,IAAI,oBAAoB,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,GAAG,oBAAoB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { serializeObject } from '../utils/serialize-object.js';
|
|
2
|
-
export function sequencerCacheKey(partition, name, args) {
|
|
3
|
-
return [
|
|
4
|
-
partition.tenant,
|
|
5
|
-
partition.realm,
|
|
6
|
-
partition.pattern,
|
|
7
|
-
partition.version,
|
|
8
|
-
name,
|
|
9
|
-
partition.run,
|
|
10
|
-
serializeObject(args),
|
|
11
|
-
].join(':');
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=sequencer-cache-key.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-cache-key.js","sourceRoot":"","sources":["../../src/processing/sequencer-cache-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,UAAU,iBAAiB,CAC/B,SAA6B,EAC7B,IAAY,EACZ,IAA4B;IAE5B,OAAO;QACL,SAAS,CAAC,MAAM;QAChB,SAAS,CAAC,KAAK;QACf,SAAS,CAAC,OAAO;QACjB,SAAS,CAAC,OAAO;QACjB,IAAI;QACJ,SAAS,CAAC,GAAG;QACb,eAAe,CAAC,IAAI,CAAC;KACtB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC"}
|
package/dist/tmp-typetest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tmp-typetest.js
DELETED
package/dist/tmp-typetest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tmp-typetest.js","sourceRoot":"","sources":["../src/tmp-typetest.ts"],"names":[],"mappings":"AAIA,MAAM,EAAE,GAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const noopSpan = { setAttribute() { } };
|
|
2
|
-
export function createNoopTelemetry() {
|
|
3
|
-
return {
|
|
4
|
-
createTracer(_name) {
|
|
5
|
-
return {
|
|
6
|
-
createSpan(_spanName, _opts, fn) {
|
|
7
|
-
return fn(noopSpan);
|
|
8
|
-
},
|
|
9
|
-
async *iterateSpan(_name, _opts, iterator) {
|
|
10
|
-
yield* iterator();
|
|
11
|
-
},
|
|
12
|
-
getContext() {
|
|
13
|
-
return {
|
|
14
|
-
traceId: '',
|
|
15
|
-
spanId: '',
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=create-noop-telemetry.js.map
|