Fix sqlitememory plugin sich that it has a configuration
category
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
+#include <config_category.h>
#include <sstream>
#include <iostream>
#include <string>
@@ -33,6 +34,16 @@ using namespace rapidjson;
*/
extern "C" {
+const char *default_config = QUOTE({
+ "poolSize" : {
+ "description" : "The number of connections to create in the intial pool of connections",
+ "type" : "integer",
+ "default" : "5",
+ "displayName" : "Pool Size",
+ "order" : "1"
+ }
+});
+
/**
* The plugin information structure
*/
@@ -41,7 +52,8 @@ static PLUGIN_INFORMATION info = {
"1.1.0", // Version
SP_READINGS, // Flags
PLUGIN_TYPE_STORAGE, // Type
- "1.6.0" // Interface version
+ "1.6.0", // Interface version
+ default_config
};
/**
@@ -56,12 +68,20 @@ PLUGIN_INFORMATION *plugin_info()
* Initialise the plugin, called to get the plugin handle
* In the case of SQLLite we also get a pool of connections
* to use.
+ *
+ * @param category The plugin configuration category
*/
-PLUGIN_HANDLE plugin_init()
+PLUGIN_HANDLE plugin_init(ConfigCategory *category)
{
ConnectionManager *manager = ConnectionManager::getInstance();
- manager->growPool(5);
+int poolSize = 5;
+
+ if (category->itemExists("poolSize"))
+ {
+ poolSize = strtol(category->getValue("poolSize").c_str(), NULL, 10);
+ }
+ manager->growPool(poolSize);
return manager;
}
/**
