Browse Source

Convert service name to use a constant rather than a getter in the microservice package

dev
David Ludwig 4 years ago
parent
commit
a5ff98a304
4 changed files with 7 additions and 7 deletions
  1. +2
    -2
      packages/microservice/src/InternalService.ts
  2. +1
    -1
      packages/microservice/src/Microservice.ts
  3. +1
    -1
      packages/microservice/src/ipc/AbstractIpcService.ts
  4. +3
    -3
      packages/microservice/src/ipc/IpcClientService.ts

+ 2
- 2
packages/microservice/src/InternalService.ts View File

@ -29,7 +29,7 @@ export abstract class InternalService<T extends Microservice = Microservice> ext
/**
* The service name
*/
public abstract get name(): string;
public abstract readonly NAME: string;
/**
* Boot the service
@ -61,6 +61,6 @@ export abstract class InternalService<T extends Microservice = Microservice> ext
if (!this.logging) {
return;
}
console.log(`[${this.name}]:`, ...args);
console.log(`[${this.NAME}]:`, ...args);
}
}

+ 1
- 1
packages/microservice/src/Microservice.ts View File

@ -156,7 +156,7 @@ export class Microservice
*/
public installService<T extends Microservice>(this: T, InternalServiceClass: InternalServiceConstructor<T>) {
let InternalService = new InternalServiceClass(this);
this.services[InternalService.name] = InternalService;
this.services[InternalService.NAME] = InternalService;
}
/**


+ 1
- 1
packages/microservice/src/ipc/AbstractIpcService.ts View File

@ -43,7 +43,7 @@ export default abstract class AbstractIpcService<M extends Microservice = Micros
public async boot() {
// Create the IPC socket
this.__ipc = new RawIPC.IPC();
this.__ipc.config.id = this.name;
this.__ipc.config.id = this.NAME;
this.__ipc.config.retry = 1500;
this.__ipc.config.silent = true;
await this.bootIpc(this.__ipc);


+ 3
- 3
packages/microservice/src/ipc/IpcClientService.ts View File

@ -41,10 +41,10 @@ export abstract class IpcClientService<M extends Microservice = Microservice> ex
public bootIpc(ipc: IPC) {
// Connect to the server
return new Promise<void>((resolve, reject) => {
this.rawIpcInstance!.connectTo(this.name, this.socketPath, () => {
this.rawIpcInstance!.connectTo(this.NAME, this.socketPath, () => {
this.__isConnected = true;
this.__requestId = 0;
this.__socket = ipc!.of[this.name];
this.__socket = ipc!.of[this.NAME];
this.installEventHandlers(this.__socket!);
this.installMessageHandlers();
resolve();
@ -74,7 +74,7 @@ export abstract class IpcClientService<M extends Microservice = Microservice> ex
* Shutdown the IPC service
*/
public async shutdownIpc(ipc: IPC|null) {
ipc?.disconnect(this.name);
ipc?.disconnect(this.NAME);
this.__socket?.removeAllListeners();
this.__socket?.destroy();
this.__socket = null;


Loading…
Cancel
Save