* Retrieve the singleton instance for a bound server. * * @typeParam T - Server type * @param ctor - The constructor that was used to make the * binding. * @returns A Promise of server instance *
(
target: Constructor<T> | string,
)
| 244 | * |
| 245 | */ |
| 246 | public async getServer<T extends Server>( |
| 247 | target: Constructor<T> | string, |
| 248 | ): Promise<T> { |
| 249 | let key: string; |
| 250 | // instanceof check not reliable for string. |
| 251 | if (typeof target === 'string') { |
| 252 | key = `${CoreBindings.SERVERS}.${target}`; |
| 253 | } else { |
| 254 | const ctor = target as Constructor<T>; |
| 255 | key = `${CoreBindings.SERVERS}.${ctor.name}`; |
| 256 | } |
| 257 | return this.get<T>(key); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Assert there is no other operation is in progress, i.e., the state is not |