Skip to content

Commit

Permalink
fix: use aws-sdk-js resource waiter delay config
Browse files Browse the repository at this point in the history
Until aws-sdk-js version 2.31.0 was recently released, the resource
waiter that we use for table creation and deletion wasn't configurable.
The (quite unreasonable high) default is `20`, which means that the
waiter waits 20 seconds until checking if the resource exists, or
doesn't exist anymore, respectively.

Now that aws-sdk-js supports configuring the waiter delay, we set it to
`1`.
  • Loading branch information
KlausTrainer committed Mar 23, 2017
1 parent f9e3ef8 commit b6f07de
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 55 deletions.
24 changes: 16 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const deserialize = require('./deserialize')
const DynamoDBIterator = require('./iterator')

const MAX_BATCH_SIZE = 25
const RESOURCE_WAITER_DELAY = 1

const globalStore = {}

Expand Down Expand Up @@ -223,7 +224,10 @@ DynamoDBDOWN.prototype.createTable = function (opts, cb) {
if (err) {
cb(err)
} else {
this.dynamoDb.waitFor('tableExists', {TableName: this.encodedTableName}, cb)
this.dynamoDb.waitFor(
'tableExists',
{TableName: this.encodedTableName, $waiter: {delay: RESOURCE_WAITER_DELAY}},
cb)
}
})
}
Expand All @@ -239,14 +243,18 @@ DynamoDBDOWN.destroy = function (name, cb) {
} else if (err) {
cb(err)
} else {
store.dynamoDb.waitFor('tableNotExists', {TableName: store.encodedTableName}, (err, data) => {
if (err) {
cb(err)
} else {
delete globalStore[name]
cb()
store.dynamoDb.waitFor(
'tableNotExists',
{TableName: store.encodedTableName, $waiter: {delay: RESOURCE_WAITER_DELAY}},
(err, data) => {
if (err) {
cb(err)
} else {
delete globalStore[name]
cb()
}
}
})
)
}
})
} else {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "index.js",
"scripts": {
"lint": "standard",
"test": "npm run lint && test/bin/run-tests",
"test": "npm run lint && tape test | tap-spec",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"author": "Klaus Trainer <klaus_trainer@apache.org>",
Expand All @@ -23,7 +23,7 @@
"leveldown"
],
"dependencies": {
"aws-sdk": "^2.6.7",
"aws-sdk": "^2.31.0",
"abstract-leveldown": "^2.6.1",
"through2": "^2.0.1"
},
Expand Down
10 changes: 0 additions & 10 deletions test/bin/run-tests

This file was deleted.

35 changes: 0 additions & 35 deletions test/node_modules/aws-sdk/apis/dynamodb-2012-08-10.waiters2.json

This file was deleted.

0 comments on commit b6f07de

Please sign in to comment.