Package ortus.boxlang.runtime.aws
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 Summary
FieldsModifier and TypeFieldDescriptionprotected Boolean
Are we in debug mode or notprotected static final String
The Lambda.bx file name by convention, which is where it's expanded by AWS Lambdaprotected Path
The absolute path to the Lambda.bx file to executeprotected String
Lambda Root where it is deployed: /var/task by conventionprotected static final ortus.boxlang.runtime.BoxRuntime
The BoxLang runtime -
Constructor Summary
ConstructorsConstructorDescriptionConstructorLambdaRunner
(Path lambdaPath, Boolean debugMode) Constructor: Useful for tests -
Method Summary
Modifier and TypeMethodDescriptionGet the lambda pathortus.boxlang.runtime.BoxRuntime
Get the BoxLang runtimeMap
<?, ?> handleRequest
(Map<String, Object> event, com.amazonaws.services.lambda.runtime.Context context) Handle the incoming request from the AWS LambdaAre we in debug modesetLambdaPath
(Path lambdaPath) Set the lambda path
-
Field Details
-
DEFAULT_LAMBDA_CLASS
The Lambda.bx file name by convention, which is where it's expanded by AWS Lambda- See Also:
-
lambdaPath
The absolute path to the Lambda.bx file to execute -
debugMode
Are we in debug mode or not -
lambdaRoot
Lambda Root where it is deployed: /var/task by convention -
runtime
protected static final ortus.boxlang.runtime.BoxRuntime runtimeThe BoxLang runtime
-
-
Constructor Details
-
LambdaRunner
public LambdaRunner()Constructor -
LambdaRunner
Constructor: Useful for tests- Parameters:
lambdaPath
- The absolute path to the Lambda.bx filedebugMode
- Are we in debug mode or not
-
-
Method Details
-
getLambdaPath
Get the lambda path- Returns:
- The absolute path to the Lambda.bx file
-
inDebugMode
Are we in debug mode- Returns:
- True if we are in debug mode
-
setLambdaPath
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 interfacecom.amazonaws.services.lambda.runtime.RequestHandler<Map<String,
Object>, Map<?, ?>> - Parameters:
event
- The incoming event as a Structcontext
- 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
-