Class: AwsLambdaRuntimeInterfaceClient::LambdaRunner
- Inherits:
-
Object
- Object
- AwsLambdaRuntimeInterfaceClient::LambdaRunner
- Defined in:
- lib/aws_lambda_ric.rb
Overview
Loads the user code and runs it upon invocation
Constant Summary collapse
- ENV_VAR_RUNTIME_API =
'AWS_LAMBDA_RUNTIME_API'
Instance Method Summary collapse
-
#initialize(runtime_server_addr, user_agent) ⇒ LambdaRunner
constructor
A new instance of LambdaRunner.
- #run(app_root, handler) ⇒ Object
Constructor Details
#initialize(runtime_server_addr, user_agent) ⇒ LambdaRunner
Returns a new instance of LambdaRunner.
29 30 31 32 33 |
# File 'lib/aws_lambda_ric.rb', line 29 def initialize(runtime_server_addr, user_agent) @lambda_server = LambdaServer.new(runtime_server_addr, user_agent) @runtime_loop_active = true # if false, we will exit the program @exit_code = 0 end |
Instance Method Details
#run(app_root, handler) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/aws_lambda_ric.rb', line 35 def run(app_root, handler) $LOAD_PATH.unshift(app_root) unless $LOAD_PATH.include?(app_root) begin @lambda_handler = LambdaHandler.new(env_handler: handler) require @lambda_handler.handler_file_name start_runtime_loop rescue Exception => e # which includes LoadError or any exception within static user code @runtime_loop_active = false @exit_code = -4 send_init_error_to_server(e) ensure TelemetryLoggingHelper.close end exit(@exit_code) end |