dynamodb-scan
v0.0.5
Published
Scans Dynamodb and emits events
Downloads
10
Maintainers
Readme
dynamodb-scan
EventEmitter to simplify dynamodb parallel scans
Features
- EventEmitter pattern for dynamodb scan
- Data event emitted for each record
- Supports pause/resume of emitter
- DynamoDb parallel scans supported
Installation
$ npm install dynamodb-scan --save
Usage
'use strict';
var DynamoDbScan = require('dynamodb-scan');
var dynamoDbScan = new DynamoDbScan('awsAccessKey', 'awsSecret', 'awsRegion', 'tableName');
var count = 0;
dynamoDbScan.on('data', function(item) {
count++;
console.dir(item);
if(count === 10)
{
dynamoDbScan.pause();
setTimeout(function() {
dynamoDbScan.resume();
}, 5000);
}
});
dynamoDbScan.on('finish', function() {
console.info('Finish');
process.exit(0);
});
dynamoDbScan.start();
Parallel Scans are useful to maximize usage of throughput provisioned on the DynamoDb table.
Documentation
new DynamoDbScan(awsAccessKeyId, awsSecretAccessKey, awsRegion, tableName, options)
Sets up the AWS credentials to use
Arguments
awsAccessKeyId
- AWS access key if not provided falls back to whatever AWS SDK can findawsSecretAccessKey
- AWS secret if not provided falls back to whatever AWS SDK can findawsRegion
- AWS region if not provided falls back to whatever AWS SDK can findtableName
- Name of table to scanoptions
- OptionsparallelScans
- Number of parallel scans to run. Defaults to 1maxRetries
- Number of times to retry a failed dynamo db operation. Passed to aws-sdk.
start()
Starts the scan. Method available so you can hook up your listeners before it starts emitting events.
pause()
Pauses a scan. Events may still be emitted from the previous scan operation.
resume()
Resumes a paused scan.
paused()
Returns true if emitter is paused
People
The author is Chris Kinsman from PushSpring