Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding success event when the putRecords call on kinesis returns data with no errors. #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

menarguez
Copy link

PR Changes:

  • Added unit tests
  • Updated README.md
  • Added success event trigger when the callback to putRecords returns with no errors, but valid data object

Description

This PR adds a success event that will be triggered on a successful write of putRecords if no errors were present

Testing

Unit tests, local testing.

  • This change adds test coverage for new/changed/fixed functionality
const KinesisStream = require('./index');

const ks = new KinesisStream({
  // accessKeyId:     'KEY_ID',
  // secretAccessKey: 'SECRET_KEY',
  region:          'xxxx',
  streamName:      'xxxx',
  partitionKey:    'MyApp'
}).on('success', (records) => {
  console.log(records)
}).on('error', (err) => {
  console.log(err)
})

const sampleRecord = {'data': 'some data'}

ks.write(new Buffer.from(JSON.stringify(sampleRecord)))
ks.write(new Buffer.from(JSON.stringify(sampleRecord)))
ks.flush()

outputs

➜  kinesis-writable git:(Add-success-event) ✗ node michaelTest.js
{
  FailedRecordCount: 0,
  Records: [
    {
      SequenceNumber: '49611750915246315708736858648611579378510795612828467202',
      ShardId: 'shardId-000000000000'
    },
    {
      SequenceNumber: '49611750915246315708736858648612788304330410242003173378',
      ShardId: 'shardId-000000000000'
    }
  ]
}

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing (There are some vulnerabilities proposed to be fixed in another PR
  • The correct base branch is being used, if not master

… with no errors.

PR Changes:
 - Added unit tests
 - Updated README.md
 - Added success event trigger when the callback to putRecords returns with no errors, but valid data object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant