firehose-publisher

1.0.0 • Public • Published

firehose-publisher CircleCI

This is a simple lib that will publish a JSON object to a Firehose stream as a gzipped one line string representation (including a newline \n at the end).

It will fail silently if the event or the stream name is missing or if there is a problem with sending it to AWS Firehose. The reason for this behaviour is that we don't want the normal flow of a service/app to fail in case of misconfiguration or errors (bearing in mind this is mostly use to send data to our datalake). We still want it to behave this way for now but that might change in the future.

Getting Started

const { publishToFirehose } = require('firehose-publisher');
const resp = publishToFirehose(event, 'my-firehose-stream-name');
if (!resp.eventSent) {
    // Logging the error if we can't send the event to firehose
    console.error('Failure to sent event to Firehose', event.error);
}

API

publishToFirehose(event, streamName, region)

  • Parameters

    1. event - JSON Object - Payload to send to Firehose stream. Must have an __origin__ field at the root.
    2. streamName - String - Firehose stream name to send the event to.
    3. region - String Optional - AWS Region where the Firehose stream resides. Defaults to process.env.AWS_REGION if present or eu-west-1 otherwise.
  • Returns an object with:

    1. eventSent - Boolean - if the event was sent successfully or not.
    2. error - Error Optional - Error caught when trying to send the event.

Readme

Keywords

none

Package Sidebar

Install

npm i firehose-publisher

Weekly Downloads

518

Version

1.0.0

License

MIT

Unpacked Size

9.65 kB

Total Files

13

Last publish

Collaborators

  • platform.chapter