Spaces:
Sleeping
Sleeping
File size: 1,338 Bytes
1305386 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import { IServiceConfig } from "../../../../interfaces/core/IServiceRegistry";
import { ServiceConfigManager } from "../../../../config/ServiceConfig";
import { Allocator } from "./Allocator";
import { PayloadDtoValidator } from "./PayloadDtoValidator";
import { Service } from "./index";
import { AggregationCounterAPI } from "../../../core/AggregationCounterAPI";
import { IWorkerRegistry } from "../../../../interfaces/core/IWorkerRegistry";
import { MESSAGE_TYPE } from "./env";
export class ServiceFactory {
static createServiceConfig(dependencies: {
aggregationCounterAPI: AggregationCounterAPI,
workerRegistry: IWorkerRegistry
}): IServiceConfig {
const typeConfig = ServiceConfigManager.getServiceConfig(MESSAGE_TYPE);
if (!typeConfig) {
throw new Error(`${MESSAGE_TYPE} service config not found (check worker profile or ServiceConfig.ts)`);
}
const allocator = new Allocator();
const payloadDtoValidator = new PayloadDtoValidator();
const service = new Service({ payloadDtoValidator });
const config: IServiceConfig = {
messageType: MESSAGE_TYPE,
service,
allocator,
payloadDtoValidator,
typeConfig
};
return config;
}
}
|