Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Created August 28, 2017 19:51
Show Gist options
  • Save theburningmonk/2e42e9fc5e1def7f85bb7872dc9ca983 to your computer and use it in GitHub Desktop.
Save theburningmonk/2e42e9fc5e1def7f85bb7872dc9ca983 to your computer and use it in GitHub Desktop.
'use strict';
const co = require('co');
const Promise = require('bluebird');
const AWS = require('aws-sdk');
const Kinesis = Promise.promisifyAll(new AWS.Kinesis());
const log = require('./log');
const requestContext = require('./requestContext');
let putRecord = co.wrap(function* (streamName, partitionKey, record) {
// save the request context as part of the payload
let ctx = requestContext.get();
record.__context = ctx;
let data = JSON.stringify(record);
let req = {
Data: data,
PartitionKey: partitionKey,
StreamName: streamName
};
yield Kinesis.putRecordAsync(req);
});
module.exports = {
putRecord
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment