next_invocation

in lib/aws_lambda_ric/lambda_server.rb [19:41]


  def next_invocation
    next_invocation_uri = URI(@server_address + '/runtime/invocation/next')
    begin
      http = Net::HTTP.new(next_invocation_uri.host, next_invocation_uri.port)
      http.read_timeout = LONG_TIMEOUT_MS
      resp = http.start do |connection|
        connection.get(next_invocation_uri.path, { 'User-Agent' => @user_agent })
      end
      if resp.is_a?(Net::HTTPSuccess)
        request_id = resp['Lambda-Runtime-Aws-Request-Id']
        [request_id, resp]
      else
        raise LambdaErrors::InvocationError.new(
          "Received #{resp.code} when waiting for next invocation."
        )
      end
    rescue LambdaErrors::InvocationError => e
      raise e
    rescue StandardError => e
      raise LambdaErrors::InvocationError.new(e)
    end
  end