How to make nodejs cassandra driver work in Lambda?

Viewed 546

Lambda not returning the callback function if I'm not closing the connection but if I do close the connection the second time the function not working and I'm getting error: "Connecting after shutdown is not supported" The code:

client.connect(function(err) {
  console.log(err);
  const query = 'SELECT * FROM table LIMIT 1';
  client.execute(query, [], {}, function(err, result) {
    if (err) {
      console.log("there was an err");
      console.log(err);
      process.exit();
    }
    else
    {
      client.shutdown(function() {
        callback(null, {});
      });
    }
  });
});

I know that it's the way it should work by: http://docs.datastax.com/en/developer/nodejs-driver/latest/faq/#should-i-shut-down-the-pool-after-executing-a-query

But is there any solution to manage the connection on Lambda?

More info on Lambda here container reuse: https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/

0 Answers
Related