Skip to content

Commit

Permalink
Driver docs define prototype for connection properties, and SPI
Browse files Browse the repository at this point in the history
getDefaultConnectionProperties() returns a new object created from
the prototype.
  • Loading branch information
jdduncan committed May 6, 2015
1 parent 35f2ac0 commit 2b055d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 10 additions & 1 deletion jones-mysql/impl/mysql_service_provider.js
Expand Up @@ -26,12 +26,16 @@ var udebug = unified_debug.getLogger("mysql_service_provider.js"),
mysqlconnection,
mysqldictionary,
fs,
propertiesDocFile,
mysqlmetadatamanager = null;

fs = {};
fs.impl_dir = __dirname;
fs.root_dir = path.dirname(fs.impl_dir);
fs.suites_dir = path.resolve(fs.root_dir, "test");
fs.docs_dir = path.join(fs.root_dir, "Documentation");

propertiesDocFile = path.join(fs.docs_dir, "mysql_properties.js");

try {
/* Let unmet module dependencies be caught by loadRequiredModules() */
Expand Down Expand Up @@ -61,8 +65,13 @@ exports.loadRequiredModules = function() {
};


function MysqlConnectionProperties() {
}

MysqlConnectionProperties.prototype = require(propertiesDocFile);

exports.getDefaultConnectionProperties = function() {
return require("../Documentation/mysql_properties.js");
return new MysqlConnectionProperties();
};


Expand Down
14 changes: 10 additions & 4 deletions jones-ndb/impl/ndb/ndb_service_provider.js
Expand Up @@ -22,6 +22,7 @@

var path = require("path");
var fs = require("fs");
var assert = require("assert");
var conf = require("./path_config");

var DatetimeConverter = require(path.join(conf.converters_dir, "NdbDatetimeConverter"));
Expand All @@ -37,10 +38,9 @@ catch(e) {
/* Let unmet module dependencies be caught by loadRequiredModules() */
}

var propertiesDocFile = path.join(conf.docs_dir, "ndb_properties");
var udebug = unified_debug.getLogger("ndb_service_provider.js");

var NdbDefaultConnectionProperties = require(path.join(conf.docs_dir, "ndb_properties"));

exports.loadRequiredModules = function() {
var err, ldp, msg;
var existsSync = fs.existsSync || path.existsSync;
Expand Down Expand Up @@ -81,9 +81,13 @@ exports.loadRequiredModules = function() {
}
};

function NdbConnectionProperties() {
}

NdbConnectionProperties.prototype = require(propertiesDocFile);

exports.getDefaultConnectionProperties = function() {
// Is this a bug? Use the docs as the constructor, not as the object
return NdbDefaultConnectionProperties;
return new NdbConnectionProperties();
};


Expand All @@ -97,6 +101,7 @@ function registerDefaultTypeConverters(dbConnectionPool) {

exports.connect = function(properties, user_callback) {
udebug.log("connect");
assert(properties.implementation === "ndb");
var dbconn = new DBConnectionPool(properties);
registerDefaultTypeConverters(dbconn);
dbconn.connect(user_callback);
Expand All @@ -105,6 +110,7 @@ exports.connect = function(properties, user_callback) {

exports.getFactoryKey = function(properties) {
udebug.log("getFactoryKey");
assert(properties.implementation === "ndb");
var key = properties.implementation + "://" + properties.ndb_connectstring;
return key;
};
Expand Down

0 comments on commit 2b055d7

Please sign in to comment.