(connection: Connection)
| 266 | } |
| 267 | |
| 268 | private async ensureNamespace(connection: Connection): Promise<void> { |
| 269 | try { |
| 270 | await connection.workflowService.describeNamespace({ |
| 271 | namespace: this.namespace, |
| 272 | }); |
| 273 | } catch (error) { |
| 274 | if (!this.isNotFoundError(error)) { |
| 275 | this.logger.error( |
| 276 | `Failed to describe Temporal namespace ${this.namespace}: ${ |
| 277 | error instanceof Error ? error.message : String(error) |
| 278 | }`, |
| 279 | ); |
| 280 | throw error; |
| 281 | } |
| 282 | |
| 283 | this.logger.log(`Registering Temporal namespace ${this.namespace}`); |
| 284 | await connection.workflowService.registerNamespace({ |
| 285 | namespace: this.namespace, |
| 286 | workflowExecutionRetentionPeriod: { seconds: Long.fromNumber(60 * 60 * 24 * 7) }, |
| 287 | }); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | private isNotFoundError(error: unknown): error is ServiceError { |
| 292 | if (!error || typeof error !== 'object') { |
no test coverage detected