Spaces:
Sleeping
Sleeping
Download src/classes/services/Default/DefaultService/ServiceFactory.ts from lamsaoganh/teamta: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/lamsaoganh/teamta/resolve/main/src/classes/services/Default/DefaultService/ServiceFactory.ts
- Command line
-
hf download hf://spaces/lamsaoganh/teamta/src/classes/services/Default/DefaultService/ServiceFactory.ts
-
curl -L -o ServiceFactory.ts https://huggingface.co/spaces/lamsaoganh/teamta/resolve/main/src/classes/services/Default/DefaultService/ServiceFactory.ts
1.34 kB
| 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; | |
| } | |
| } | |