dynamodb-streams-readable
Simple readable stream client for AWS DynamoDB Streams
Last updated 2 months ago by godu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dynamodb-streams-readable 
SYNC missed versions from official npm registry.

dynamodb-streams-readable

Node.js stream interface for reading records from AWS DynamoDB Streams.

Usage

var AWS = new AWS.DynamoDBStreams({
  region: 'us-east-1'
});

// see below for options
var readable = require('dynamodb-streams-readable')(client, options);

readable
  // 'data' events will trigger for a set of records in the stream
  .on('data', function(records) {
    console.log(records);
  })
  // each time a records are passed downstream, the 'checkpoint' event will provide
  // the last sequence number that has been read
  .on('checkpoint', function(sequenceNumber) {
    console.log(sequenceNumber);
  })
  .on('error', function(err) {
    console.error(err);
  })
  .on('end', function() {
    console.log('all done!');
  });

// Calling .close() will finish all pending GetRecord requests before emitting
// the 'end' event.
// Because the kinesis stream persists, the readable stream will not
// 'end' until you explicitly close it
setTimeout(function() {
  readable.close();
}, 60 * 60 * 1000);

Options

You can pass options to create the readable stream, all parameters are optional:

var options = {
  shardId: 'shard-identifier', // defaults to first shard in the stream
  iterator: 'LATEST', // default to TRIM_HORIZON
  startAfter: '12345678901234567890', // start reading after this sequence number
  startAt: '12345678901234567890', // start reading from this sequence number
  limit: 100 // number of records per `data` event
};

Inspired by @rclark's kinesis-readable.

Current Tags

  • 1.0.7                                ...           latest (2 months ago)
  • 1.0.7                                ...           next (2 months ago)

8 Versions

  • 1.0.7                                ...           2 months ago
  • 1.0.6                                ...           2 months ago
  • 1.0.5                                ...           5 months ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 3
Last Month 2
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |