Created
August 28, 2017 19:51
-
-
Save theburningmonk/2e42e9fc5e1def7f85bb7872dc9ca983 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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