Class LambdaRunner

java.lang.Object
ortus.boxlang.runtime.aws.LambdaRunner
All Implemented Interfaces:
com.amazonaws.services.lambda.runtime.RequestHandler<Map<String,Object>,Map<?,?>>

public class LambdaRunner extends Object implements com.amazonaws.services.lambda.runtime.RequestHandler<Map<String,Object>,Map<?,?>>
The BoxLang AWS Lambda Runner

This class is the entry point for the AWS Lambda runtime. It is responsible for handling the incoming request, invoking the Lambda.bx file, and returning the response.

The Lambda.bx file is expected to contain a `run` method that accepts the incoming event, the AWS Lambda context, and the response. The response is expected to be a struct with the following

  • statusCode: The HTTP status code
  • headers: A struct of headers
  • body: The response body

The Lambda.bx file is expected to be in the current directory and named `Lambda.bx`.

The incoming event is expected to be a map of strings.

The response is expected to be a JSON string.

The Lambda.bx file is compiled and executed using the BoxLang runtime.

The runtime is started up and shutdown for each request.

  • Field Details

    • DEFAULT_LAMBDA_CLASS

      protected static final String DEFAULT_LAMBDA_CLASS
      The Lambda.bx file name by convention, which is where it's expanded by AWS Lambda
      See Also:
    • lambdaPath

      protected Path lambdaPath
      The absolute path to the Lambda.bx file to execute
    • debugMode

      protected Boolean debugMode
      Are we in debug mode or not
    • lambdaRoot

      protected String lambdaRoot
      Lambda Root where it is deployed: /var/task by convention
    • runtime

      protected static final ortus.boxlang.runtime.BoxRuntime runtime
      The BoxLang runtime
  • Constructor Details

    • LambdaRunner

      public LambdaRunner()
      Constructor
    • LambdaRunner

      public LambdaRunner(Path lambdaPath, Boolean debugMode)
      Constructor: Useful for tests
      Parameters:
      lambdaPath - The absolute path to the Lambda.bx file
      debugMode - Are we in debug mode or not
  • Method Details

    • getLambdaPath

      public Path getLambdaPath()
      Get the lambda path
      Returns:
      The absolute path to the Lambda.bx file
    • inDebugMode

      public Boolean inDebugMode()
      Are we in debug mode
      Returns:
      True if we are in debug mode
    • setLambdaPath

      public LambdaRunner setLambdaPath(Path lambdaPath)
      Set the lambda path
      Parameters:
      lambdaPath - The absolute path to the Lambda.bx file
      Returns:
      The LambdaRunner instance
    • getRuntime

      public ortus.boxlang.runtime.BoxRuntime getRuntime()
      Get the BoxLang runtime
    • handleRequest

      public Map<?,?> handleRequest(Map<String,Object> event, com.amazonaws.services.lambda.runtime.Context context)
      Handle the incoming request from the AWS Lambda
      Specified by:
      handleRequest in interface com.amazonaws.services.lambda.runtime.RequestHandler<Map<String,Object>,Map<?,?>>
      Parameters:
      event - The incoming event as a Struct
      context - The AWS Lambda context
      Returns:
      The response as a JSON string
      Throws:
      ortus.boxlang.runtime.types.exceptions.BoxRuntimeException - If the Lambda.bx file is not found or does not contain a `run` method