@rewaa/event-broker
Advanced tools
Comparing version 7.2.1 to 7.2.2
@@ -12,2 +12,3 @@ import { AttributeValue, GetItemCommandInput, DynamoDB, DynamoDBClientConfig, CreateTableCommandOutput, PutItemCommandInput, CreateTableCommandInput } from "@aws-sdk/client-dynamodb"; | ||
createTable(command: CreateTableCommandInput): Promise<CreateTableCommandOutput | undefined>; | ||
private waitForTableActive; | ||
} |
@@ -6,3 +6,2 @@ "use strict"; | ||
const constants_1 = require("./constants"); | ||
const utils_1 = require("./utils"); | ||
class DynamoClient { | ||
@@ -42,3 +41,3 @@ constructor(logger, config) { | ||
if (expiryKey) { | ||
await (0, utils_1.delay)(1000); | ||
await this.waitForTableActive(command.TableName); | ||
await this.client.updateTimeToLive({ | ||
@@ -64,4 +63,27 @@ TableName: command.TableName, | ||
} | ||
async waitForTableActive(tableName) { | ||
var _a; | ||
this.logger.info(`Waiting for table ${tableName} to become ACTIVE`); | ||
let status = "CREATING"; | ||
while (status === "CREATING") { | ||
try { | ||
const data = await this.client.describeTable({ TableName: tableName }); | ||
status = (_a = data.Table) === null || _a === void 0 ? void 0 : _a.TableStatus; | ||
this.logger.debug(`Current status of table ${tableName}: ${status}`); | ||
} | ||
catch (error) { | ||
if (error.name === "ResourceNotFoundException") { | ||
this.logger.debug(`Table ${tableName} not found, retrying...`); | ||
} | ||
else { | ||
throw error; | ||
} | ||
} | ||
if (status !== "ACTIVE") { | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait 5 seconds | ||
} | ||
} | ||
} | ||
} | ||
exports.DynamoClient = DynamoClient; | ||
//# sourceMappingURL=dynamo.client.js.map |
{ | ||
"name": "@rewaa/event-broker", | ||
"version": "7.2.1", | ||
"version": "7.2.2", | ||
"description": "A broker for all the events that Rewaa will ever produce or consume", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
353430
2675