I'm using a singleton pattern for mySQL connections in node.js, there's one and only one connection for the whole application to use, my concern is if there's some timeout setting for this connection held by the singleton.
This connection is supposed to live throughout the life cycle of the app. I searched and found some persistence examples using pool but not sure if this applies to this example, there's no pool of connections, there's only one connection to be shared between the components, the question is, is there some timeout setting that will kill the connection after it's held for long?
puremvc.define(
{
name: "common.model.connections.App",
constructor: function() {
var mysql = require("mysql");
this.connection = mysql.createConnection({
host: common.Config.mySQLHost,
user: common.Config.mySQLUsername,
password: common.Config.mySQLPassword,
database: common.Config.mySQLDatabase
});
this.connection.connect();
}
},
{
},
{
NAME: "App",
instance: null,
connection: null,
getInstance: function() {
if(common.model.connections.App.instance == null) {
common.model.connections.App.instance = new common.model.connections.Fico();
}
return common.model.connections.App.instance;
},
getConnection: function() {
return common.model.connections.App.getInstance().connection;
}
}
);