Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/dynamoFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const AWS = require('aws-sdk'),
AWSDaxClient = require('amazon-dax-client'),
OSTBase = require('@ostdotcom/base'),
coreConstant = require(rootPrefix + '/config/coreConstant'),
logger = require(rootPrefix + '/lib/logger/customConsoleLogger'),
util = require(rootPrefix + '/lib/util');

const InstanceComposer = OSTBase.InstanceComposer;
Expand Down Expand Up @@ -74,6 +75,7 @@ DynamoConfigFactory.prototype = {
logger: configStrategies.storage.enableLogging == 1 ? console : '',
retryDelayOptions: {
customBackoff: function(retryCount) {
logger.debug(`DDB Retry customBackoff called for retryCount: ${retryCount}`);
return coreConstant.fixedRetryAfterTime() + retryCount * coreConstant.variableRetryAfterTime();
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ostdotcom/storage",
"version": "1.0.3",
"version": "1.0.4-beta.1",
"description": "OST storage provides data storage and sharding services.",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 2 additions & 4 deletions services/dynamodb/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,11 @@ DDBServiceBase.prototype = {
const oThis = this;

let r = oThis.validateParams();
logger.debug('=======Base.validateParams.result=======');
logger.debug(r);

if (r.isFailure()) return r;

r = await oThis.executeDdbRequest();
logger.debug('=======Base.executeDdbRequest.result=======');
logger.debug(r);

return r;
},

Expand Down
10 changes: 5 additions & 5 deletions services/dynamodb/BatchGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ const batchGetPrototype = {
localResponse = await oThis.batchGetItemAfterWait(batchGetParams, waitTime);

if (!localResponse.isSuccess()) {
if (localResponse.internalErrorCode.includes('ResourceNotFoundException')) {
if (
localResponse.internalErrorCode.includes('ResourceNotFoundException') ||
localResponse.internalErrorCode.includes('ProvisionedThroughputExceededException')
) {
logger.error(
'services/dynamodb/BatchGet.js:executeDdbRequest, ResourceNotFoundException : attemptNo: ',
`services/dynamodb/BatchGet.js:executeDdbRequest, ${localResponse.internalErrorCode} : attemptNo: `,
attemptNo
);
localResponse.data['UnprocessedKeys'] = batchGetParams['RequestItems'];
Expand Down Expand Up @@ -161,9 +164,6 @@ const batchGetPrototype = {
}
}

logger.debug('=======Base.perform.result=======');
logger.debug(globalResponse);

return globalResponse;
} catch (err) {
logger.error('services/dynamodb/BatchGet.js:executeDdbRequest inside catch ', err);
Expand Down
15 changes: 10 additions & 5 deletions services/dynamodb/BatchWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ const batchWritePrototype = {
response = await oThis.batchWriteItemAfterWait(batchWriteParams, waitTime);

if (!response.isSuccess()) {
if (response.internalErrorCode.includes('ResourceNotFoundException')) {
if (
response.internalErrorCode.includes('ResourceNotFoundException') ||
response.internalErrorCode.includes('ProvisionedThroughputExceededException')
) {
logger.error(
'services/dynamodb/BatchWrite.js:executeDdbRequest, ResourceNotFoundException : attemptNo: ',
`services/dynamodb/BatchWrite.js:executeDdbRequest, ${response.internalErrorCode} : attemptNo: `,
attemptNo
);
response.data['UnprocessedItems'] = batchWriteParams['RequestItems'];
Expand Down Expand Up @@ -139,8 +142,6 @@ const batchWritePrototype = {
}
}

logger.debug('=======Base.perform.result=======');
logger.debug(response);
return response;
} catch (err) {
logger.error('services/dynamodb/BatchWrite.js:executeDdbRequest inside catch ', err);
Expand Down Expand Up @@ -177,6 +178,10 @@ const batchWritePrototype = {
Object.assign(DDBServiceBatchWriteItem.prototype, batchWritePrototype);
DDBServiceBatchWriteItem.prototype.constructor = batchWritePrototype;

InstanceComposer.registerAsShadowableClass(DDBServiceBatchWriteItem, coreConstant.icNameSpace, 'DDBServiceBatchWriteItem');
InstanceComposer.registerAsShadowableClass(
DDBServiceBatchWriteItem,
coreConstant.icNameSpace,
'DDBServiceBatchWriteItem'
);

module.exports = DDBServiceBatchWriteItem;
2 changes: 0 additions & 2 deletions services/dynamodb/WaitFor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ const waitForPrototype = {
.ic()
.getInstanceFor(coreConstant.icNameSpace, 'libDynamoDBBase')
.queryDdb(oThis.methodName, 'raw', oThis.waitForMethod, oThis.params);
logger.debug('=======Base.perform.result=======');
logger.debug(r);
return r;
} catch (err) {
logger.error('services/dynamodb/Base.js:executeDdbRequest inside catch ', err);
Expand Down