diff --git a/source/app.d b/source/app.d index 4211cde..63f8494 100644 --- a/source/app.d +++ b/source/app.d @@ -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()); } diff --git a/source/bootstrap.d b/source/bootstrap.d index 3fbb692..960f8e8 100644 --- a/source/bootstrap.d +++ b/source/bootstrap.d @@ -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 @@ -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");