Skip to content

Transform records from a Kinesis Firehose stream from Avro encoded JSON to JSON.

Notifications You must be signed in to change notification settings

NYPL/firehose-avro-to-json-transformer

Repository files navigation

Kinesis Firehose Avro to Json Transformer Lambda

Build Status

This app reads from Firehose Kinesis streams, decodes the records using the appropriate Avro schema based on the stream name, and returns the resulting records as either JSON or CSV (base64 encoded). This app is responsible for decoding records immediately before ingest into the BIC.

Version

v1.0.1

Installation

Install all Node dependencies via NPM

nvm use
npm install

Running Locally

Use the sam cli to run the lambda on arbitrary firehose events. To process a firehose event containing 3 CircTrans records and print out the result:

sam local invoke --profile nypl-digital-dev -t sam.qa.yml -e sample/firehose-CircTrans-3-records-encoded.json

Contributing

This repo uses the "PRs Target Main, Merge to Deployment Branches" git workflow:

  • Cut PRs from main
  • Merge main > qa
  • Merge main > production

Deployment

This app is deployed via Travis-CI using terraform. Code in qa is pushed to AvroToJsonTransformer-qa. Code in production is pushed to AvroToJsonTransformer-production.

Tests

To run all tests found in ./test/:

npm run test

To run a specific test for the given filename:

npm run test [filename].test.js

Test Coverage

This repo uses c8 to compute test coverage (because Istanbul doesn't appear to support ESM at writing). Coverage reports are included at the end of npm test. For a detailed line-by-line breakdown, view the HTML report:

npm run coverage-report
open coverage/index.html

Linting

This codebase uses Standard JS as the JavaScript linter.

To check for linting errors:

npm run lint

About

Transform records from a Kinesis Firehose stream from Avro encoded JSON to JSON.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published