Skip to content

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

Open
menarguez wants to merge 1 commit intoauth0:masterfrom
menarguez:Add-success-event
Open

Adding success event when the putRecords call on kinesis returns data with no errors.#47
menarguez wants to merge 1 commit intoauth0:masterfrom
menarguez:Add-success-event

Conversation

@menarguez
Copy link
Copy Markdown

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