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
var net = require('net'); | |
var repl = require('repl'); | |
var util = require('util'); | |
var awslambda = require('./build/Release/awslambda'); | |
const BASE_CONTEXT = Object.freeze({ | |
logGroupName: process.env['AWS_LAMBDA_LOG_GROUP_NAME'], | |
logStreamName: process.env['AWS_LAMBDA_LOG_STREAM_NAME'], | |
functionName: process.env['AWS_LAMBDA_FUNCTION_NAME'], | |
memoryLimitInMB: process.env['AWS_LAMBDA_FUNCTION_MEMORY_SIZE'], |
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
let spanCounter = -1; | |
const HTTP_FILTER_RATIO = 2; | |
const thundra = require("@thundra/core")({ | |
traceConfig: { | |
disableRequest: true, | |
disableResponse: true, | |
runCustomSamplerOnEachSpan: true, | |
sampler: { | |
isSampled(span) { |
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
const thundra = require("@thundra/core")(); | |
exports.handler_blocking = thundra((event, context, callback) => { | |
setTimeout(function () { | |
callback(null, {msg: event}); | |
}, 5000); | |
while (true); | |
}); |
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
const thundra = require("@thundra/core")(); | |
const mongoose = require('mongoose'); | |
let conn = null; | |
const uri = 'your mongo connection here'; | |
exports.handler = thundra(async function(event) { | |
if (conn == null) { | |
conn = await mongoose.connect(uri, {useNewUrlParser: true}); | |
conn.model('Test', new mongoose.Schema({ name: String })); |
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 thundra = require("@thundra/core")(); | |
const MongoClient = require('mongodb').MongoClient; | |
const MONGODB_URI = process.env.MONGODB_URI; | |
let cachedDb = null; | |
function connectToDatabase (uri) { | |
console.log('=> connect to database'); |
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 thundra = require("@thundra/core")(); | |
const MongoClient = require('mongodb').MongoClient; | |
const MONGODB_URI = process.env.MONGODB_URI; | |
let cachedDb = null; | |
function connectToDatabase (uri) { | |
console.log('=> connect to database'); |
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
// Require and initialize outside of your main handler | |
const thundra = require('@thundra/core')(); | |
const mysql = require('serverless-mysql')({ | |
config: { | |
host : '', | |
database : '', | |
user : '', | |
password : '', |
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
let {exec} = require('child_process'); | |
exports.handler = (event, context, callback) => { | |
exec(event.cmd, (err, stdout, stderr) => { | |
console.log(stdout); | |
if (err) console.log(stderr); | |
callback(undefined, {statusCode: 200}); | |
}); | |
} |
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
const thundra = require("@thundra/core")(); | |
const vandium = require('vandium'); | |
exports.handler = thundra(vandium.api() | |
.GET((event) => { | |
return 'Hello ' + event.pathParameters.name + '!'; | |
})); |
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
const thundra = require('@thundra/core'); | |
exports.handler = thundra({ | |
apiKey : <Your API Key> | |
})((event, context, callback) => { | |
const tracer = thundra.tracer(); | |
const span = tracer.startSpan('say-hello'); | |
try { | |
const message = sayHello('Thundra'); |
NewerOlder