module Bootstrap

Bootstrap runtime

Public Class Methods

bootstrap_handler() click to toggle source
# File lib/aws_lambda_ric/bootstrap.rb, line 26
def self.bootstrap_handler
  if ARGV.empty?
    puts 'No handler specified, exiting Runtime Interface Client.'
    exit
  end
  app_root = Dir.pwd
  handler = ARGV[0]
  lambda_runner = AwsLambdaRuntimeInterfaceClient::LambdaRunner.new(fetch_runtime_server, get_user_agent)
  puts "Executing '#{handler}' in function directory '#{app_root}'"
  lambda_runner.run(app_root, handler)
end
bootstrap_telemetry_log_sink(path_to_fd='/proc/self/fd/') click to toggle source
# File lib/aws_lambda_ric/bootstrap.rb, line 18
def self.bootstrap_telemetry_log_sink(path_to_fd='/proc/self/fd/')
  fd = ENV.fetch(AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper::ENV_VAR_TELEMETRY_LOG_FD)
  ENV.delete(AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper::ENV_VAR_TELEMETRY_LOG_FD)
  AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.new(fd, path_to_fd)
rescue KeyError
  puts 'Skipped bootstraping TelemetryLog'
end
fetch_runtime_server() click to toggle source
# File lib/aws_lambda_ric/bootstrap.rb, line 11
def self.fetch_runtime_server
  ENV.fetch(AwsLambdaRuntimeInterfaceClient::LambdaRunner::ENV_VAR_RUNTIME_API)
rescue KeyError
  puts 'Failed to get runtime server address from AWS_LAMBDA_RUNTIME_API env variable'
  exit(-2)
end
get_user_agent() click to toggle source
# File lib/aws_lambda_ric/bootstrap.rb, line 38
def self.get_user_agent
  ruby_version = RUBY_VERSION.to_s
  version = AwsLambdaRuntimeInterfaceClient::VERSION
 
  "aws-lambda-ruby/#{ruby_version}-#{version}"
end
start() click to toggle source
# File lib/aws_lambda_ric/bootstrap.rb, line 6
def self.start
  bootstrap_telemetry_log_sink
  bootstrap_handler
end