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
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ env:
- OS_CACHING_ENGINE=memcached
- OST_MEMCACHE_SERVERS=127.0.0.1:11211
node_js:
- "8"
- "12"
- "10"
services:
- memcached
before_install:
- sudo apt-get update
- sudo apt-get install nodejs
- sudo apt-get install npm
- sudo apt-get update
- sudo apt-get install nodejs
- sudo apt-get install npm
install:
- npm install
- npm install
before_script:
- mkdir -p dynamodb
- wget https://s3.ap-south-1.amazonaws.com/dynamodb-local-mumbai/dynamodb_local_latest.zip -O ./dynamodb/dynamodb_local_latest.zip
Expand All @@ -39,4 +40,4 @@ script:
after_script:
- kill $(ps aux | grep 'DynamoDBLocal.jar' | awk '{print $2}')
- rm -rf dynamodb
- rm -rf dynamodb_instance_2
- rm -rf dynamodb_instance_2
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Storage v1.0.4
- Upgraded node version to 10.x
- Version bump for dependencies.

## Storage v1.0.3
- Integrated with new Instance Composer.
- Migrated to ES6.
Expand All @@ -23,4 +27,4 @@
- Auto Scale services to scale read/write capacity of DynamoDB tables.
- Cache layer on top of Shard management services.
- Model layer for token_balances and transaction_logs to support respective queries to DynamoDB.
- Cache layer on top of token_balances.
- Cache layer on top of token_balances.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.0.4
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
6 changes: 3 additions & 3 deletions 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",
"description": "OST storage provides data storage and sharding services.",
"main": "index.js",
"scripts": {
Expand All @@ -17,14 +17,14 @@
"OST Storage",
"DynamoDB"
],
"author": "OST.COM LTD.",
"author": "OST.com Inc.",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/ostdotcom/storage/issues"
},
"homepage": "https://github.com/ostdotcom/storage#readme",
"dependencies": {
"@ostdotcom/base": "1.0.0",
"@ostdotcom/base": "^2.0.0",
"aws-sdk": "2.263.1",
"amazon-dax-client": "1.1.3",
"bignumber.js": "4.1.0"
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