tangled
alpha
login
or
join now
cosmik.network
/
semble
43
fork
atom
A social knowledge tool for researchers built on ATProto
43
fork
atom
overview
issues
13
pulls
pipelines
formatting and linting
Wesley Finck
4 months ago
62769998
7681987c
+17
-5
3 changed files
expand all
collapse all
unified
split
src
modules
cards
tests
integration
BullMQEventSystem.integration.test.ts
shared
infrastructure
processes
BaseWorkerProcess.ts
FeedWorkerProcess.ts
+3
-1
src/modules/cards/tests/integration/BullMQEventSystem.integration.test.ts
···
291
291
it('should handle distributed saga state across multiple workers', async () => {
292
292
// Arrange - Create two saga instances (simulating multiple workers)
293
293
const mockUseCase = {
294
294
-
execute: jest.fn().mockResolvedValue(ok({ activityId: 'test-activity' })),
294
294
+
execute: jest
295
295
+
.fn()
296
296
+
.mockResolvedValue(ok({ activityId: 'test-activity' })),
295
297
} as any;
296
298
297
299
const stateStore = new RedisSagaStateStore(redis);
+7
-2
src/shared/infrastructure/processes/BaseWorkerProcess.ts
···
2
2
import { EnvironmentConfigService } from '../config/EnvironmentConfigService';
3
3
import { QueueName } from '../events/QueueConfig';
4
4
import { IEventSubscriber } from '../../application/events/IEventSubscriber';
5
5
-
import { RepositoryFactory, Repositories } from '../http/factories/RepositoryFactory';
5
5
+
import {
6
6
+
RepositoryFactory,
7
7
+
Repositories,
8
8
+
} from '../http/factories/RepositoryFactory';
6
9
import { WorkerServices } from '../http/factories/ServiceFactory';
7
10
8
11
export abstract class BaseWorkerProcess implements IProcess {
···
29
32
}
30
33
31
34
protected abstract createServices(repositories: Repositories): WorkerServices;
32
32
-
protected abstract validateDependencies(services: WorkerServices): Promise<void>;
35
35
+
protected abstract validateDependencies(
36
36
+
services: WorkerServices,
37
37
+
): Promise<void>;
33
38
protected abstract registerHandlers(
34
39
subscriber: IEventSubscriber,
35
40
services: WorkerServices,
+7
-2
src/shared/infrastructure/processes/FeedWorkerProcess.ts
···
1
1
import { EnvironmentConfigService } from '../config/EnvironmentConfigService';
2
2
-
import { ServiceFactory, WorkerServices } from '../http/factories/ServiceFactory';
2
2
+
import {
3
3
+
ServiceFactory,
4
4
+
WorkerServices,
5
5
+
} from '../http/factories/ServiceFactory';
3
6
import { UseCaseFactory } from '../http/factories/UseCaseFactory';
4
7
import { CardAddedToLibraryEventHandler } from '../../../modules/feeds/application/eventHandlers/CardAddedToLibraryEventHandler';
5
8
import { CardAddedToCollectionEventHandler } from '../../../modules/feeds/application/eventHandlers/CardAddedToCollectionEventHandler';
···
20
23
return ServiceFactory.createForWorker(this.configService, repositories);
21
24
}
22
25
23
23
-
protected async validateDependencies(services: WorkerServices): Promise<void> {
26
26
+
protected async validateDependencies(
27
27
+
services: WorkerServices,
28
28
+
): Promise<void> {
24
29
if (!services.redisConnection) {
25
30
throw new Error('Redis connection required for feed worker');
26
31
}