1.0.0 • Published 2 years ago

firehose-publisher v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.