@cratis/chronicle 6.51.0 → 6.52.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/ChronicleClient.ts +127 -99
- package/ChronicleOptions.ts +23 -0
- package/dist/ChronicleClient.d.ts +7 -0
- package/dist/ChronicleClient.d.ts.map +1 -1
- package/dist/ChronicleClient.js +115 -95
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/ChronicleOptions.d.ts +14 -0
- package/dist/ChronicleOptions.d.ts.map +1 -1
- package/dist/ChronicleOptions.js +16 -0
- package/dist/ChronicleOptions.js.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts +12 -0
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +202 -175
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/PreparedBatchAppend.d.ts +4 -0
- package/dist/eventSequences/PreparedBatchAppend.d.ts.map +1 -0
- package/dist/eventSequences/PreparedBatchAppend.js +4 -0
- package/dist/eventSequences/PreparedBatchAppend.js.map +1 -0
- package/dist/eventSequences/PreparedSingleAppend.d.ts +4 -0
- package/dist/eventSequences/PreparedSingleAppend.d.ts.map +1 -0
- package/dist/eventSequences/PreparedSingleAppend.js +4 -0
- package/dist/eventSequences/PreparedSingleAppend.js.map +1 -0
- package/dist/eventSequences/WireBatchEvent.d.ts +6 -0
- package/dist/eventSequences/WireBatchEvent.d.ts.map +1 -0
- package/dist/eventSequences/WireBatchEvent.js +4 -0
- package/dist/eventSequences/WireBatchEvent.js.map +1 -0
- package/dist/eventSequences/toContractsCausation.d.ts +16 -0
- package/dist/eventSequences/toContractsCausation.d.ts.map +1 -0
- package/dist/eventSequences/toContractsCausation.js +15 -0
- package/dist/eventSequences/toContractsCausation.js.map +1 -0
- package/dist/observation/FastForwardOutcome.d.ts +14 -0
- package/dist/observation/FastForwardOutcome.d.ts.map +1 -0
- package/dist/observation/FastForwardOutcome.js +17 -0
- package/dist/observation/FastForwardOutcome.js.map +1 -0
- package/dist/observation/FastForwardResult.d.ts +14 -0
- package/dist/observation/FastForwardResult.d.ts.map +1 -0
- package/dist/observation/FastForwardResult.js +4 -0
- package/dist/observation/FastForwardResult.js.map +1 -0
- package/dist/observation/IObservers.d.ts +9 -0
- package/dist/observation/IObservers.d.ts.map +1 -1
- package/dist/observation/Observers.d.ts +3 -0
- package/dist/observation/Observers.d.ts.map +1 -1
- package/dist/observation/Observers.js +11 -0
- package/dist/observation/Observers.js.map +1 -1
- package/dist/observation/index.d.ts +3 -0
- package/dist/observation/index.d.ts.map +1 -1
- package/dist/observation/index.js +2 -0
- package/dist/observation/index.js.map +1 -1
- package/dist/observation/toFastForwardResult.d.ts +16 -0
- package/dist/observation/toFastForwardResult.d.ts.map +1 -0
- package/dist/observation/toFastForwardResult.js +37 -0
- package/dist/observation/toFastForwardResult.js.map +1 -0
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +3 -1
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/reducers/ReducerObservation.d.ts +18 -0
- package/dist/reducers/ReducerObservation.d.ts.map +1 -0
- package/dist/reducers/ReducerObservation.js +4 -0
- package/dist/reducers/ReducerObservation.js.map +1 -0
- package/dist/reducers/ReducerObservationSession.d.ts +11 -0
- package/dist/reducers/ReducerObservationSession.d.ts.map +1 -0
- package/dist/reducers/ReducerObservationSession.js +4 -0
- package/dist/reducers/ReducerObservationSession.js.map +1 -0
- package/dist/reducers/Reducers.d.ts +9 -0
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +150 -154
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/reducers/ReductionOutcome.d.ts +25 -0
- package/dist/reducers/ReductionOutcome.d.ts.map +1 -0
- package/dist/reducers/ReductionOutcome.js +66 -0
- package/dist/reducers/ReductionOutcome.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webhooks/WebhookDefinitionBuilder.d.ts.map +1 -1
- package/dist/webhooks/WebhookDefinitionBuilder.js +3 -1
- package/dist/webhooks/WebhookDefinitionBuilder.js.map +1 -1
- package/dist/webhooks/Webhooks.d.ts.map +1 -1
- package/dist/webhooks/Webhooks.js +3 -1
- package/dist/webhooks/Webhooks.js.map +1 -1
- package/eventSequences/EventSequence.ts +265 -186
- package/eventSequences/PreparedBatchAppend.ts +7 -0
- package/eventSequences/PreparedSingleAppend.ts +7 -0
- package/eventSequences/WireBatchEvent.ts +7 -0
- package/eventSequences/toContractsCausation.ts +17 -0
- package/for_ChronicleClient/messageSizes.spec.ts +37 -0
- package/for_ChronicleOptions/when_configuring_message_sizes/with_message_sizes.spec.ts +29 -0
- package/observation/FastForwardOutcome.ts +19 -0
- package/observation/FastForwardResult.ts +19 -0
- package/observation/IObservers.ts +10 -0
- package/observation/Observers.spec.ts +41 -4
- package/observation/Observers.ts +14 -0
- package/observation/index.ts +3 -0
- package/observation/toFastForwardResult.ts +40 -0
- package/package.json +2 -2
- package/reactors/Reactors.ts +3 -1
- package/reducers/ReducerObservation.ts +25 -0
- package/reducers/ReducerObservationSession.ts +15 -0
- package/reducers/Reducers.ts +186 -171
- package/reducers/ReductionOutcome.ts +75 -0
- package/webhooks/WebhookDefinitionBuilder.ts +3 -1
- package/webhooks/Webhooks.ts +3 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { chai, describe, it } from 'vitest';
|
|
5
|
+
import { ChronicleOptions } from '../../ChronicleOptions.js';
|
|
6
|
+
|
|
7
|
+
chai.should();
|
|
8
|
+
|
|
9
|
+
const hundredMegabytes = 100 * 1024 * 1024;
|
|
10
|
+
|
|
11
|
+
describe('when configuring message sizes', () => {
|
|
12
|
+
it('should allow 100 MB in both directions by default, matching the other clients', () => {
|
|
13
|
+
const options = ChronicleOptions.fromConnectionString('chronicle://localhost:35000');
|
|
14
|
+
options.maxReceiveMessageSize!.should.equal(hundredMegabytes);
|
|
15
|
+
options.maxSendMessageSize!.should.equal(hundredMegabytes);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should use the configured sizes', () => {
|
|
19
|
+
const options = ChronicleOptions.development({ maxReceiveMessageSize: 200, maxSendMessageSize: 300 });
|
|
20
|
+
options.maxReceiveMessageSize!.should.equal(200);
|
|
21
|
+
options.maxSendMessageSize!.should.equal(300);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should keep null as null so the gRPC default can be asked for explicitly', () => {
|
|
25
|
+
const options = ChronicleOptions.development({ maxReceiveMessageSize: null, maxSendMessageSize: null });
|
|
26
|
+
(options.maxReceiveMessageSize === null).should.be.true;
|
|
27
|
+
(options.maxSendMessageSize === null).should.be.true;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents the outcome of fast forwarding an observer.
|
|
6
|
+
*/
|
|
7
|
+
export enum FastForwardOutcome {
|
|
8
|
+
/** The observer was moved to the tail of the event sequence. */
|
|
9
|
+
FastForwarded = 'FastForwarded',
|
|
10
|
+
|
|
11
|
+
/** The observer was already at the tail of the event sequence, so nothing was changed. */
|
|
12
|
+
AlreadyAtTail = 'AlreadyAtTail',
|
|
13
|
+
|
|
14
|
+
/** The observer is replaying, so it cannot be fast forwarded until the replay has completed. */
|
|
15
|
+
Replaying = 'Replaying',
|
|
16
|
+
|
|
17
|
+
/** The observer is retired or removed, so nothing was changed. */
|
|
18
|
+
NotAvailable = 'NotAvailable'
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import type { EventSequenceNumber } from '../eventSequences/EventSequenceNumber.js';
|
|
5
|
+
import type { FastForwardOutcome } from './FastForwardOutcome.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents the result of fast forwarding an observer.
|
|
9
|
+
*/
|
|
10
|
+
export interface FastForwardResult {
|
|
11
|
+
/** What happened. */
|
|
12
|
+
readonly outcome: FastForwardOutcome;
|
|
13
|
+
|
|
14
|
+
/** The next event sequence number the observer expected before the fast forward. */
|
|
15
|
+
readonly previousNextEventSequenceNumber: EventSequenceNumber;
|
|
16
|
+
|
|
17
|
+
/** The next event sequence number the observer expects after the fast forward. */
|
|
18
|
+
readonly nextEventSequenceNumber: EventSequenceNumber;
|
|
19
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
|
+
import { FastForwardResult } from './FastForwardResult.js';
|
|
4
5
|
import { ObserverInformation } from './ObserverInformation.js';
|
|
5
6
|
import { ObserverRemovalResult } from './ObserverRemovalResult.js';
|
|
6
7
|
|
|
@@ -29,4 +30,13 @@ export interface IObservers {
|
|
|
29
30
|
* @returns An {@link ObserverRemovalResult} describing what happened.
|
|
30
31
|
*/
|
|
31
32
|
remove(observerId: string): Promise<ObserverRemovalResult>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Fast forwards an observer to the tail of the event log, skipping every event it has not yet handled
|
|
36
|
+
* without invoking it. Its failed partitions are discarded. State it has already built is kept, so the
|
|
37
|
+
* effect of the skipped events is missing from it; replay the observer instead to rebuild.
|
|
38
|
+
* @param observerId - The identifier of the observer to fast forward.
|
|
39
|
+
* @returns A {@link FastForwardResult} describing what happened and where the observer is now.
|
|
40
|
+
*/
|
|
41
|
+
fastForward(observerId: string): Promise<FastForwardResult>;
|
|
32
42
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
|
-
import { ObserverRemovalOutcome as ContractObserverRemovalOutcome, ObserverRunningState as ContractObserverRunningState, ObserverType as ContractObserverType } from '@cratis/chronicle.contracts';
|
|
4
|
+
import { FastForwardOutcome as ContractFastForwardOutcome, ObserverRemovalOutcome as ContractObserverRemovalOutcome, ObserverRunningState as ContractObserverRunningState, ObserverType as ContractObserverType } from '@cratis/chronicle.contracts';
|
|
5
5
|
import { describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import type { ChronicleConnection } from '../connection/index.js';
|
|
7
|
+
import { FastForwardOutcome } from './FastForwardOutcome.js';
|
|
7
8
|
import { ObserverRemovalOutcome } from './ObserverRemovalOutcome.js';
|
|
8
9
|
import { ObserverRunningState } from './ObserverRunningState.js';
|
|
9
10
|
import { ObserverType } from './ObserverType.js';
|
|
@@ -21,14 +22,17 @@ function wireObserverInformation() {
|
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
function createObservers(getObserversResult?: unknown, removeObserverResult?: unknown) {
|
|
25
|
+
function createObservers(getObserversResult?: unknown, removeObserverResult?: unknown, fastForwardResult?: unknown) {
|
|
26
|
+
const fastForward = vi.fn().mockResolvedValue(
|
|
27
|
+
fastForwardResult ?? { Outcome: ContractFastForwardOutcome.FastForwarded, PreviousNextEventSequenceNumber: 5n, NextEventSequenceNumber: 101n }
|
|
28
|
+
);
|
|
25
29
|
const getObservers = vi.fn().mockResolvedValue(getObserversResult ?? { items: [] });
|
|
26
30
|
const removeObserver = vi.fn().mockResolvedValue(
|
|
27
31
|
removeObserverResult ?? { Outcome: ContractObserverRemovalOutcome.Removed, BlockingNamespace: '' }
|
|
28
32
|
);
|
|
29
|
-
const connection = { observers: { getObservers, removeObserver } } as unknown as ChronicleConnection;
|
|
33
|
+
const connection = { observers: { getObservers, removeObserver, fastForward } } as unknown as ChronicleConnection;
|
|
30
34
|
const observers = new Observers('my-event-store', 'my-namespace', connection);
|
|
31
|
-
return { observers, getObservers, removeObserver };
|
|
35
|
+
return { observers, getObservers, removeObserver, fastForward };
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
describe('Observers', () => {
|
|
@@ -112,4 +116,37 @@ describe('Observers', () => {
|
|
|
112
116
|
expect(result.blockingNamespace).toEqual('production');
|
|
113
117
|
});
|
|
114
118
|
});
|
|
119
|
+
|
|
120
|
+
describe('when fast forwarding an observer', () => {
|
|
121
|
+
it('should ask for that observer on the event log', async () => {
|
|
122
|
+
const { observers, fastForward } = createObservers();
|
|
123
|
+
await observers.fastForward('employee-alerts');
|
|
124
|
+
|
|
125
|
+
const request = fastForward.mock.calls[0][0];
|
|
126
|
+
expect(request.EventStore).toEqual('my-event-store');
|
|
127
|
+
expect(request.Namespace).toEqual('my-namespace');
|
|
128
|
+
expect(request.ObserverId).toEqual('employee-alerts');
|
|
129
|
+
expect(request.EventSequenceId).toEqual('event-log');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should report what happened and where the observer is now', async () => {
|
|
133
|
+
const { observers } = createObservers();
|
|
134
|
+
const result = await observers.fastForward('employee-alerts');
|
|
135
|
+
|
|
136
|
+
expect(result.outcome).toEqual(FastForwardOutcome.FastForwarded);
|
|
137
|
+
expect(result.previousNextEventSequenceNumber.value).toEqual(5n);
|
|
138
|
+
expect(result.nextEventSequenceNumber.value).toEqual(101n);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should report a replaying observer as replaying', async () => {
|
|
142
|
+
const { observers } = createObservers(undefined, undefined, {
|
|
143
|
+
Outcome: ContractFastForwardOutcome.ObserverReplaying,
|
|
144
|
+
PreviousNextEventSequenceNumber: 5n,
|
|
145
|
+
NextEventSequenceNumber: 5n
|
|
146
|
+
});
|
|
147
|
+
const result = await observers.fastForward('employee-alerts');
|
|
148
|
+
|
|
149
|
+
expect(result.outcome).toEqual(FastForwardOutcome.Replaying);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
115
152
|
});
|
package/observation/Observers.ts
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { ChronicleConnection } from '../connection/index.js';
|
|
5
5
|
import { EventSequenceId } from '../eventSequences/EventSequenceId.js';
|
|
6
|
+
import { FastForwardResult } from './FastForwardResult.js';
|
|
6
7
|
import { IObservers } from './IObservers.js';
|
|
7
8
|
import { ObserverInformation } from './ObserverInformation.js';
|
|
8
9
|
import { ObserverRemovalResult } from './ObserverRemovalResult.js';
|
|
10
|
+
import { toFastForwardResult } from './toFastForwardResult.js';
|
|
9
11
|
import { toObserverInformation } from './toObserverInformation.js';
|
|
10
12
|
import { toObserverRemovalResult } from './toObserverRemovalResult.js';
|
|
11
13
|
|
|
@@ -46,4 +48,16 @@ export class Observers implements IObservers {
|
|
|
46
48
|
|
|
47
49
|
return toObserverRemovalResult(response);
|
|
48
50
|
}
|
|
51
|
+
|
|
52
|
+
/** @inheritdoc */
|
|
53
|
+
async fastForward(observerId: string): Promise<FastForwardResult> {
|
|
54
|
+
const response = await this._connection.observers.fastForward({
|
|
55
|
+
EventStore: this._eventStore,
|
|
56
|
+
Namespace: this._namespace,
|
|
57
|
+
ObserverId: observerId,
|
|
58
|
+
EventSequenceId: EventSequenceId.eventLog.value
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return toFastForwardResult(response);
|
|
62
|
+
}
|
|
49
63
|
}
|
package/observation/index.ts
CHANGED
|
@@ -14,6 +14,9 @@ export { toObserverInformation, toObserverType } from './toObserverInformation.j
|
|
|
14
14
|
export { ObserverRemovalOutcome } from './ObserverRemovalOutcome.js';
|
|
15
15
|
export type { ObserverRemovalResult } from './ObserverRemovalResult.js';
|
|
16
16
|
export { toObserverRemovalOutcome, toObserverRemovalResult } from './toObserverRemovalResult.js';
|
|
17
|
+
export { FastForwardOutcome } from './FastForwardOutcome.js';
|
|
18
|
+
export type { FastForwardResult } from './FastForwardResult.js';
|
|
19
|
+
export { toFastForwardOutcome, toFastForwardResult } from './toFastForwardResult.js';
|
|
17
20
|
export type { IObservers } from './IObservers.js';
|
|
18
21
|
export { Observers } from './Observers.js';
|
|
19
22
|
export type { ICanBeNotifiedWhenReplay } from './ICanBeNotifiedWhenReplay.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { FastForwardOutcome as ContractFastForwardOutcome, FastForwardResponse } from '@cratis/chronicle.contracts';
|
|
5
|
+
import { EventSequenceNumber } from '../eventSequences/EventSequenceNumber.js';
|
|
6
|
+
import { FastForwardOutcome } from './FastForwardOutcome.js';
|
|
7
|
+
import { FastForwardResult } from './FastForwardResult.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts a wire {@link ContractFastForwardOutcome} into the client {@link FastForwardOutcome}.
|
|
11
|
+
* @param outcome - The wire outcome to convert.
|
|
12
|
+
* @returns The converted client outcome.
|
|
13
|
+
*/
|
|
14
|
+
export function toFastForwardOutcome(outcome: ContractFastForwardOutcome): FastForwardOutcome {
|
|
15
|
+
switch (outcome) {
|
|
16
|
+
case ContractFastForwardOutcome.FastForwarded:
|
|
17
|
+
return FastForwardOutcome.FastForwarded;
|
|
18
|
+
case ContractFastForwardOutcome.AlreadyAtTail:
|
|
19
|
+
return FastForwardOutcome.AlreadyAtTail;
|
|
20
|
+
case ContractFastForwardOutcome.ObserverReplaying:
|
|
21
|
+
return FastForwardOutcome.Replaying;
|
|
22
|
+
case ContractFastForwardOutcome.NotAvailable:
|
|
23
|
+
return FastForwardOutcome.NotAvailable;
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Unknown fast forward outcome: ${outcome}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Converts a wire {@link FastForwardResponse} into the client {@link FastForwardResult}.
|
|
31
|
+
* @param response - The wire response to convert.
|
|
32
|
+
* @returns The converted client result.
|
|
33
|
+
*/
|
|
34
|
+
export function toFastForwardResult(response: FastForwardResponse): FastForwardResult {
|
|
35
|
+
return {
|
|
36
|
+
outcome: toFastForwardOutcome(response.Outcome),
|
|
37
|
+
previousNextEventSequenceNumber: new EventSequenceNumber(response.PreviousNextEventSequenceNumber),
|
|
38
|
+
nextEventSequenceNumber: new EventSequenceNumber(response.NextEventSequenceNumber)
|
|
39
|
+
};
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/chronicle",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.52.0",
|
|
4
4
|
"description": "Event sourcing for TypeScript and Node.js — the idiomatic client for Cratis Chronicle, the open-source event-sourcing database",
|
|
5
5
|
"author": "Cratis",
|
|
6
6
|
"license": "MIT",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
},
|
|
179
179
|
"dependencies": {
|
|
180
180
|
"@bufbuild/protobuf": "^2.16.0",
|
|
181
|
-
"@cratis/chronicle.contracts": "19.
|
|
181
|
+
"@cratis/chronicle.contracts": "19.56.1",
|
|
182
182
|
"@grpc/grpc-js": "^1.14.5",
|
|
183
183
|
"@opentelemetry/api": "^1.9.1",
|
|
184
184
|
"glob": "^13.0.6",
|
package/reactors/Reactors.ts
CHANGED
|
@@ -5,7 +5,7 @@ import 'reflect-metadata';
|
|
|
5
5
|
import { createLogger } from '../logging/createLogger.js';
|
|
6
6
|
import { runInBackgroundContext } from '../telemetry/runInBackgroundContext.js';
|
|
7
7
|
import { Constructor } from '@cratis/fundamentals';
|
|
8
|
-
import { ObservationState, ReactorMessage, ReplayState } from '@cratis/chronicle.contracts';
|
|
8
|
+
import { EventGenerationDelivery, ObservationState, ReactorMessage, ReplayState } from '@cratis/chronicle.contracts';
|
|
9
9
|
import { IClientArtifactsProvider } from '../artifacts/index.js';
|
|
10
10
|
import { ChronicleConnection } from '../connection/index.js';
|
|
11
11
|
import { ConnectionLifecycle } from '../connection/ConnectionLifecycle.js';
|
|
@@ -276,6 +276,8 @@ export class Reactors implements IReactors {
|
|
|
276
276
|
Key: EVENT_SOURCE_ID_KEY
|
|
277
277
|
})),
|
|
278
278
|
IsReplayable: !isOnceOnly(reactorType),
|
|
279
|
+
IsNotReplayable: isOnceOnly(reactorType),
|
|
280
|
+
GenerationDelivery: EventGenerationDelivery.Compatibility,
|
|
279
281
|
Tags: getTagsFor(reactorType).map(t => t.value),
|
|
280
282
|
Filters: {
|
|
281
283
|
FilterTags: getFilterTagsFor(reactorType).map(t => t.value),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Constructor } from '@cratis/fundamentals';
|
|
5
|
+
import { ReducerEventDispatcher } from './ReducerEventDispatcher.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Identifies a single reducer observation: the reducer, where it observes and how its events are dispatched.
|
|
9
|
+
*/
|
|
10
|
+
export interface ReducerObservation {
|
|
11
|
+
/** The reducer identifier. */
|
|
12
|
+
readonly id: string;
|
|
13
|
+
|
|
14
|
+
/** The reducer type. */
|
|
15
|
+
readonly reducerType: Constructor;
|
|
16
|
+
|
|
17
|
+
/** The event sequence the reducer observes. */
|
|
18
|
+
readonly eventSequenceId: string;
|
|
19
|
+
|
|
20
|
+
/** The identifier of the read model the reducer produces. */
|
|
21
|
+
readonly readModelName: string;
|
|
22
|
+
|
|
23
|
+
/** The dispatcher routing events to the reducer's handlers. */
|
|
24
|
+
readonly dispatcher: ReducerEventDispatcher;
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { ReducerObservation } from './ReducerObservation.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A {@link ReducerObservation} that is running against an open observation stream.
|
|
8
|
+
*/
|
|
9
|
+
export interface ReducerObservationSession extends ReducerObservation {
|
|
10
|
+
/** Aborted when the observation is stopped. */
|
|
11
|
+
readonly signal: AbortSignal;
|
|
12
|
+
|
|
13
|
+
/** The long-lived reducer instance, or undefined when instances are activated per delivery. */
|
|
14
|
+
readonly reducerInstance: Record<string, Function> | undefined;
|
|
15
|
+
}
|