Skip to content

chriskinsman/dynamodb-scan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dynamodb-scan

Travis Build NPM Version NPM Downloads

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 find
  • awsSecretAccessKey - AWS secret if not provided falls back to whatever AWS SDK can find
  • awsRegion - AWS region if not provided falls back to whatever AWS SDK can find
  • tableName - Name of table to scan
  • options - Options
    • parallelScans - Number of parallel scans to run. Defaults to 1
    • maxRetries - 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

License

MIT

About

EventEmitter to simplify dynamodb parallel scans

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published