-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial renaming and refactor (removing the pods)
- Loading branch information
Showing
17 changed files
with
126 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import type { IOperation, IOperationResult } from '../service/IService'; | ||
import type { IOperation } from '../service/IService'; | ||
|
||
export interface IServiceRegistry { | ||
get descriptions(): string[]; | ||
initializeServices: () => Promise<void>; | ||
run: (operation: IOperation) => Promise<IOperationResult | undefined>; | ||
run: (operation: IOperation) => Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type { IOperation, IService } from '../service/IService'; | ||
import type { ICostQueueFactory } from '../cost-queue/ICostQueue'; | ||
import type { IServiceRegistry } from './IServiceRegistry'; | ||
|
||
export class ServiceRegistryHardcodedTestOnly implements IServiceRegistry { | ||
public readonly costQueueFactory: ICostQueueFactory; | ||
public readonly services: IService[]; | ||
|
||
public constructor( | ||
aggregatorServices: { service: IService; operations: IOperation[] }[], | ||
costQueueFactory: ICostQueueFactory, | ||
) { | ||
this.services = aggregatorServices.map((aggregatorService): IService => aggregatorService.service); | ||
this.costQueueFactory = costQueueFactory; | ||
for (const aggregatorService of aggregatorServices) { | ||
for (const operation of aggregatorService.operations) { | ||
aggregatorService.service.test(operation).then( | ||
(testResult): void => { | ||
if (!testResult.runnable) { | ||
throw new Error('Operation not runnable'); | ||
} | ||
aggregatorService.service.run(operation).catch( | ||
(error): void => { | ||
throw new Error( | ||
`Aggregator Service:\n${aggregatorService.service.description.toString()}\n` + | ||
`failed to 'run' on operation:\n${JSON.stringify(operation)}\nwith error:\n${error}`, | ||
); | ||
}, | ||
); | ||
}, | ||
).catch((error): void => { | ||
throw new Error( | ||
`Aggregator Service:\n${aggregatorService.service.description.toString()}\n` + | ||
`failed to 'test' on operation:\n${JSON.stringify(operation)}\nwith error:\n${error}`, | ||
); | ||
}); | ||
} | ||
} | ||
} | ||
|
||
public async run(operation: IOperation): Promise<void> { | ||
throw new Error(`Service registry not changeable ${JSON.stringify(operation)}.`); | ||
} | ||
|
||
public get descriptions(): string[] { | ||
const result = []; | ||
for (const service of this.services) { | ||
result.push(service.description.toString()); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.