Skip to content

Commit

Permalink
refs #2,#6 Add a simple harness from app.d and add debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
truedat101 committed Feb 19, 2019
1 parent d8deeea commit 491ef15
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 27 additions & 1 deletion source/app.d
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
import std.stdio;
import std.json;

import lambd.layer;
import lambd.bootstrap;

void main()
{
writeln("Edit source/app.d to start your project.");
//
// Initialize the context
// Normally this is coming from the AWS Lambda infrastructure
auto myctx = LambdaContext ("myfunc",
"somefakearn",
"1.0.0",
512, /* mb */
"someloggroupname",
"somelogstreamname",
"somefakeawsrequestID",
3000, /* only run for 3000ms */
parseJSON("{}"), /* Fill in with an AWS identity JSON */
parseJSON("{}") /* Fill in with some AWS client context */
);
//
// Create a fake event
//
JSONValue evt = parseJSON("{}");
evt.object["count"] = JSONValue(20);
// XXX TODO: Move this into some test harness code
// For now this serves as an executable tester
JSONValue result = handler(evt, myctx);

// dump to string for visual inspection
writeln("results:", result.toString());
}
4 changes: 4 additions & 0 deletions source/bootstrap.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import lambd.layer;
// - some cool crypto stuff
// - break the Internet

//
// YOU SHOULD DELETE EVERYTHING BELOW HERE AND REPLACE WITH YOUR OWN LAMBDA
//
// For this quick example, we will simply generate UUIDs
// event should contain:
// - (optional) inputdata: [] array, with input data strings
Expand All @@ -32,6 +35,7 @@ import lambd.layer;
// TODO: Implement
} else if (const(JSONValue)* count = "count" in evt) {
uuidcount = to!int(count.integer);
writeln("Generate ", uuidcount, " UUIDs");
} else {
// assume count = 1;
writeln("Performing default UUID gen count = 1");
Expand Down

0 comments on commit 491ef15

Please sign in to comment.