UNPKG

@duongtrungnguyen/nestro

Version:
48 lines 1.75 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index); import { Inject, Injectable } from "@nestjs/common"; import { STORAGE, STORAGE_OPTIONS } from "../../storage"; import { debugLog } from "../../common"; let RegistryService = class { constructor(storageOptions, storage) { this.storageOptions = storageOptions; this.storage = storage; } beforeApplicationShutdown() { debugLog("Nestro server", "Nestro server stopping"); } async register(service) { const key = service.name; await this.storage.register(key, service); return { heartbeatInterval: this.storageOptions.heartbeatInterval }; } async deregister(service) { await this.storage.deregister(service.name, service); return { message: "Deregistered" }; } async heartbeat(service) { await this.storage.heartbeat(service.name, service); return { message: "Heartbeat received" }; } async getServices(serviceName) { return await this.storage.getServices(serviceName); } }; RegistryService = __decorateClass([ Injectable(), __decorateParam(0, Inject(STORAGE_OPTIONS)), __decorateParam(1, Inject(STORAGE)) ], RegistryService); export { RegistryService }; //# sourceMappingURL=registry.service.js.map