firehose-publisher
v1.0.0
Published
Simple AWS Firehose publisher
Downloads
335
Readme
firehose-publisher
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
event
- JSON Object - Payload to send to Firehose stream. Must have an__origin__
field at the root.streamName
- String - Firehose stream name to send the event to.region
- String Optional - AWS Region where the Firehose stream resides. Defaults toprocess.env.AWS_REGION
if present oreu-west-1
otherwise.
Returns an object with:
eventSent
- Boolean - if the event was sent successfully or not.error
- Error Optional - Error caught when trying to send the event.