This file contains 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 EventEmitter = require('events'); | |
const Promise = require('bluebird'); | |
const AWS = require('aws-sdk'); | |
const ssm = Promise.promisifyAll(new AWS.SSM()); | |
const DEFAULT_EXPIRY = 3 * 60 * 1000; // default expiry is 3 mins |
This file contains 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
// the KinesisHandler abstraction takes in a function that processes one | |
// record at a time so to allow us to inject the correlation IDs that | |
// corresponds to each record | |
module.exports.handler = kinesisHandler( | |
co.wrap(function* (record, context) { | |
reqContext.set("source-type", "kinesis"); | |
let host = reqContext.get()["x-correlation-host"]; | |
if (host) { | |
let uri = `https://${host}/dev/api-c`; |
This file contains 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) { |
This file contains 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 log = require('./log'); | |
const reqContext = require('./requestContext'); | |
function getEvents (records) { | |
// parse the Kinesis records (base64) as JSON | |
} |
This file contains 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 log = require('../lib/log'); | |
const snsHandler = require('../lib/snsHandler'); | |
const http = require('../lib/http'); | |
const reqContext = require('../lib/requestContext'); | |
module.exports.handler = snsHandler( | |
co.wrap(function* (event, context) { |
This file contains 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 log = require('./log'); | |
const reqContext = require('./requestContext'); | |
function setRequestContext (event, context) { | |
// extra correlation-ids, User-Agent, etc. from the message attribute and | |
// populate the requestContext with them | |
}; |
This file contains 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 SNS = Promise.promisifyAll(new AWS.SNS()); | |
const log = require('./log'); | |
const requestContext = require('./requestContext'); | |
function getMessageAttributes() { |
This file contains 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 log = require('../lib/log'); | |
const http = require('../lib/http'); | |
const apiHandler = require('../lib/apiHandler'); | |
const reqContext = require('../lib/requestContext'); | |
module.exports.handler = apiHandler( | |
co.wrap(function* (event, context) { |
This file contains 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 log = require('./log'); | |
const reqContext = require('./requestContext'); | |
function setRequestContext (event, context) { | |
// extracts correlation IDs, User-Agent, etc. from HTTP headers | |
// and stores them in the requestContext | |
}; |
This file contains 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 reqContext = require('./requestContext'); | |
function getContext () { | |
// note: this is a shallow copy | |
return Object.assign({}, reqContext.get()); | |
} | |
function isDebugEnabled () { |