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
const lookupService = (name, timeoutService = 100) => { | |
if (!_services[name]) return Promise.reject(`Unknown service <${name}>`) | |
let svc = _services[name] | |
let timeout | |
return Promise.race([ | |
svc.promise, | |
new Promise((resolve, reject) => { | |
timeout = global.setTimeout(() => { | |
reject(new Error(`Time out looking up service <${name}>`)) | |
}, timeoutService) |