Browse Source

Prevent duplicate service registration in microservice application

dev
David Ludwig 4 years ago
parent
commit
3cd46d8f47
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      packages/microservice/src/Microservice.ts

+ 3
- 0
packages/microservice/src/Microservice.ts View File

@ -160,6 +160,9 @@ export class Microservice
*/
public installService<T extends Microservice>(this: T, InternalServiceClass: InternalServiceConstructor<T>) {
let InternalService = new InternalServiceClass(this);
if (InternalService.NAME in this.services) {
throw new Error("Install Service Error: Attempted to register multiple services with the same name");
}
this.services[InternalService.NAME] = InternalService;
}


Loading…
Cancel
Save