Skip to content

Commit 6ee0821

Browse files
committed
upd
1 parent c4900c1 commit 6ee0821

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

lib/event_processor/event_processor_factory.spec.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -227,46 +227,52 @@ describe('getBatchEventProcessor', () => {
227227
});
228228

229229

230-
it('uses a IntervalRepeater with default flush interval and adds a startup log if flushInterval is not provided', () => {
230+
it('uses default batch size and adds a startup log if flushInterval is not provided', () => {
231231
const options = {
232232
eventDispatcher: getMockEventDispatcher(),
233+
defaultBatchSize: 77,
234+
defaultFlushInterval: 12345,
233235
};
234236

235237
const processor = getBatchEventProcessor(options);
236238

237239
expect(Object.is(processor, MockBatchEventProcessor.mock.instances[0])).toBe(true);
238-
expect(MockBatchEventProcessor.mock.calls[0][0].batchSize).toBe(DEFAULT_EVENT_BATCH_SIZE);
240+
expect(MockBatchEventProcessor.mock.calls[0][0].batchSize).toBe(77);
239241

240242
const startupLogs = MockBatchEventProcessor.mock.calls[0][0].startupLogs;
241243
expect(startupLogs).toEqual(expect.arrayContaining([{
242244
level: LogLevel.Warn,
243245
message: 'Invalid batchSize %s, defaulting to %s',
244-
params: [undefined, DEFAULT_EVENT_BATCH_SIZE],
246+
params: [undefined, 77],
245247
}]));
246248
});
247249

248250
it('uses default size and adds a startup log if provided batchSize is less than 1', () => {
249251
const options = {
250252
eventDispatcher: getMockEventDispatcher(),
251253
batchSize: -1,
254+
defaultBatchSize: 77,
255+
defaultFlushInterval: 12345,
252256
};
253257

254258
const processor = getBatchEventProcessor(options);
255259

256260
expect(Object.is(processor, MockBatchEventProcessor.mock.instances[0])).toBe(true);
257-
expect(MockBatchEventProcessor.mock.calls[0][0].batchSize).toBe(DEFAULT_EVENT_BATCH_SIZE);
261+
expect(MockBatchEventProcessor.mock.calls[0][0].batchSize).toBe(77);
258262

259263
const startupLogs = MockBatchEventProcessor.mock.calls[0][0].startupLogs;
260264
expect(startupLogs).toEqual(expect.arrayContaining([{
261265
level: LogLevel.Warn,
262266
message: 'Invalid batchSize %s, defaulting to %s',
263-
params: [-1, DEFAULT_EVENT_BATCH_SIZE],
267+
params: [-1, 77],
264268
}]));
265269
});
266270

267271
it('does not use a failedEventRepeater if failedEventRetryInterval is not provided', () => {
268272
const options = {
269273
eventDispatcher: getMockEventDispatcher(),
274+
defaultBatchSize: 77,
275+
defaultFlushInterval: 12345,
270276
};
271277

272278
const processor = getBatchEventProcessor(options);
@@ -279,6 +285,8 @@ describe('getBatchEventProcessor', () => {
279285
const options = {
280286
eventDispatcher: getMockEventDispatcher(),
281287
failedEventRetryInterval: 12345,
288+
defaultBatchSize: 77,
289+
defaultFlushInterval: 12345,
282290
};
283291

284292
const processor = getBatchEventProcessor(options);
@@ -292,6 +300,8 @@ describe('getBatchEventProcessor', () => {
292300
const eventDispatcher = getMockEventDispatcher();
293301
const options = {
294302
eventDispatcher,
303+
defaultBatchSize: 77,
304+
defaultFlushInterval: 12345,
295305
};
296306

297307
const processor = getBatchEventProcessor(options);
@@ -303,6 +313,8 @@ describe('getBatchEventProcessor', () => {
303313
it('does not use any closingEventDispatcher if not provided', () => {
304314
const options = {
305315
eventDispatcher: getMockEventDispatcher(),
316+
defaultBatchSize: 77,
317+
defaultFlushInterval: 12345,
306318
};
307319

308320
const processor = getBatchEventProcessor(options);
@@ -316,6 +328,8 @@ describe('getBatchEventProcessor', () => {
316328
const options = {
317329
eventDispatcher: getMockEventDispatcher(),
318330
closingEventDispatcher,
331+
defaultBatchSize: 77,
332+
defaultFlushInterval: 12345,
319333
};
320334

321335
const processor = getBatchEventProcessor(options);
@@ -329,6 +343,8 @@ describe('getBatchEventProcessor', () => {
329343
const options = {
330344
eventDispatcher: getMockEventDispatcher(),
331345
eventStore,
346+
defaultBatchSize: 77,
347+
defaultFlushInterval: 12345,
332348
};
333349

334350
const processor = getBatchEventProcessor(options);

lib/event_processor/event_processor_factory.universal.ts

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import {
2525
getPrefixEventStore,
2626
} from './event_processor_factory';
2727

28+
export const DEFAULT_EVENT_BATCH_SIZE = 10;
29+
export const DEFAULT_EVENT_FLUSH_INTERVAL = 1_000;
30+
2831
import { FAILED_EVENT_RETRY_INTERVAL } from './event_processor_factory';
2932

3033
export const createForwardingEventProcessor = (
@@ -47,6 +50,8 @@ export const createBatchEventProcessor = (
4750
closingEventDispatcher: options.closingEventDispatcher,
4851
flushInterval: options.flushInterval,
4952
batchSize: options.batchSize,
53+
defaultFlushInterval: DEFAULT_EVENT_FLUSH_INTERVAL,
54+
defaultBatchSize: DEFAULT_EVENT_BATCH_SIZE,
5055
retryOptions: {
5156
maxRetries: 5,
5257
},

0 commit comments

Comments
 (0)