@iobroker/db-states-jsonl
Advanced tools
Comparing version 7.0.2 to 7.0.3
@@ -21,2 +21,6 @@ "use strict"; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
@@ -40,4 +44,7 @@ mod | ||
autoCompress: { | ||
// Compress when the number of uncompressed entries has grown a lot | ||
sizeFactor: 10, | ||
sizeFactorMinimumSize: 5e4, | ||
// Compress at least daily to avoid a huge file when DBs have few objects | ||
// but big binary states are updated regularly | ||
intervalMs: 1e3 * 60 * 60 * 23 | ||
@@ -51,4 +58,7 @@ }, | ||
lockfile: { | ||
// 5 retries starting at 250ms add up to just above 2s, | ||
// so the DB has 3 more seconds to load all data if it wants to stay within the 5s connectionTimeout | ||
retries: 5, | ||
retryMinTimeoutMs: 250, | ||
// This makes sure the DB stays locked for maximum 2s even if the process crashes | ||
staleMs: 2e3 | ||
@@ -96,8 +106,21 @@ } | ||
this.dataset = new Proxy(this._db, { | ||
/** | ||
* @param target | ||
* @param prop | ||
*/ | ||
get(target, prop) { | ||
return target.get(prop); | ||
}, | ||
/** | ||
* @param target | ||
* @param prop | ||
*/ | ||
has(target, prop) { | ||
return target.has(prop); | ||
}, | ||
/** | ||
* @param target | ||
* @param prop | ||
* @param value | ||
*/ | ||
set(target, prop, value) { | ||
@@ -107,2 +130,6 @@ target.set(prop, value); | ||
}, | ||
/** | ||
* @param target | ||
* @param prop | ||
*/ | ||
deleteProperty(target, prop) { | ||
@@ -114,2 +141,6 @@ return target.delete(prop); | ||
}, | ||
/** | ||
* @param target | ||
* @param prop | ||
*/ | ||
getOwnPropertyDescriptor(target, prop) { | ||
@@ -133,2 +164,8 @@ if (!target.has(prop)) { | ||
} | ||
/** | ||
* Checks if an existing file DB should be migrated to JSONL | ||
* | ||
* @returns true if the file DB was migrated. false if not. | ||
* If this returns true, the jsonl DB was opened and doesn't need to be opened again. | ||
*/ | ||
async _maybeMigrateFileDB() { | ||
@@ -189,2 +226,3 @@ const jsonlFileName = import_node_path.default.join(this.dataDir, this.settings.jsonlDB.fileName); | ||
} | ||
// Is regularly called and stores a compressed backup of the DB | ||
async saveBackup() { | ||
@@ -191,0 +229,0 @@ const now = Date.now(); |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
/** | ||
@@ -3,0 +2,0 @@ * This class inherits statesInMemoryFileDB class and adds socket.io communication layer |
@@ -21,2 +21,6 @@ "use strict"; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
@@ -38,2 +42,7 @@ mod | ||
class StatesInMemoryServer extends import_statesInMemJsonlDB.StatesInMemoryJsonlDB { | ||
/** | ||
* Constructor | ||
* | ||
* @param settings State and InMem-DB settings | ||
*/ | ||
constructor(settings) { | ||
@@ -62,2 +71,9 @@ super(settings); | ||
} | ||
/** | ||
* Separate Namespace from ID and return both | ||
* | ||
* @param idWithNamespace ID or Array of IDs containing a redis namespace and the real ID | ||
* @returns Object with namespace and the | ||
* ID/Array of IDs without the namespace | ||
*/ | ||
_normalizeId(idWithNamespace) { | ||
@@ -86,2 +102,11 @@ let ns = this.namespaceStates; | ||
} | ||
/** | ||
* Publish a subscribed value to one of the redis connections in redis format | ||
* | ||
* @param client Instance of RedisHandler | ||
* @param type Type of subscribed key | ||
* @param id Subscribed ID | ||
* @param obj Object to publish | ||
* @returns Publish counter 0 or 1 depending if send out or not | ||
*/ | ||
publishToClients(client, type, id, obj) { | ||
@@ -116,2 +141,7 @@ if (!client._subscribe || !client._subscribe[type]) { | ||
} | ||
/** | ||
* Register all event listeners for Handler and implement the relevant logic | ||
* | ||
* @param handler RedisHandler instance | ||
*/ | ||
_socketEvents(handler) { | ||
@@ -339,5 +369,13 @@ let connectionName = null; | ||
} | ||
/** | ||
* Return connected RedisHandlers/Connections | ||
* | ||
* @returns | ||
*/ | ||
getClients() { | ||
return this.serverConnections; | ||
} | ||
/** | ||
* Destructor of the class. Called by shutting down. | ||
*/ | ||
async destroy() { | ||
@@ -363,2 +401,7 @@ if (this.server) { | ||
} | ||
/** | ||
* Initialize RedisHandler for a new network connection | ||
* | ||
* @param socket Network socket | ||
*/ | ||
_initSocket(socket) { | ||
@@ -381,2 +424,8 @@ this.settings.connection.enhancedLogging && this.log.silly(`${this.namespace} Handling new Redis States connection`); | ||
} | ||
/** | ||
* Initialize Redis Server | ||
* | ||
* @param settings Settings object | ||
* @returns | ||
*/ | ||
_initRedisServer(settings) { | ||
@@ -383,0 +432,0 @@ return new Promise((resolve, reject) => { |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
/** | ||
@@ -3,0 +2,0 @@ * This class inherits statesInMemoryFileDB class and adds socket.io communication layer |
{ | ||
"name": "@iobroker/db-states-jsonl", | ||
"type": "module", | ||
"version": "7.0.2", | ||
"version": "7.0.3", | ||
"engines": { | ||
@@ -10,5 +10,5 @@ "node": ">=12.0.0" | ||
"@alcalzone/jsonl-db": "~3.1.1", | ||
"@iobroker/db-base": "7.0.2", | ||
"@iobroker/db-states-file": "7.0.2", | ||
"@iobroker/db-states-redis": "7.0.2" | ||
"@iobroker/db-base": "7.0.3", | ||
"@iobroker/db-states-file": "7.0.3", | ||
"@iobroker/db-states-redis": "7.0.3" | ||
}, | ||
@@ -51,3 +51,3 @@ "keywords": [ | ||
], | ||
"gitHead": "06427179951aa037bdf485c0ea2483142c10d903" | ||
"gitHead": "1c716ca37fe7c26d4f56571f90d33be69d45726e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204458
1818
+ Added@iobroker/db-base@7.0.3(transitive)
+ Added@iobroker/db-states-file@7.0.3(transitive)
+ Added@iobroker/db-states-redis@7.0.3(transitive)
+ Added@iobroker/js-controller-common-db@7.0.3(transitive)
- Removed@iobroker/db-base@7.0.2(transitive)
- Removed@iobroker/db-states-file@7.0.2(transitive)
- Removed@iobroker/db-states-redis@7.0.2(transitive)
- Removed@iobroker/js-controller-common-db@7.0.2(transitive)
Updated@iobroker/db-base@7.0.3