@iobroker/db-objects-file 4.0.0-alpha.45-20220114-88aaebdb → 4.0.0-alpha.49-20220121-e7aa4308
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -7
- package/lib/objects/objectsInMemServerRedis.js +42 -18
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -35,8 +35,7 @@ The simulator supports four different namespaces:
|
|
|
35
35
|
| punsubscribe | full | objects |
|
|
36
36
|
| config | dummy | independent |
|
|
37
37
|
| client | partial | independent |
|
|
38
|
-
| multi |
|
|
39
|
-
| exec | dummy | independent |
|
|
38
|
+
| multi/exec | partial | independent |
|
|
40
39
|
| sadd | dummy | independent |
|
|
41
40
|
| srem | dummy | independent |
|
|
42
41
|
| sscan |full | objects, files, sets |
|
|
@@ -102,11 +101,9 @@ Mainly a dummy, just sends a positive response if `lua-time-limit` change receiv
|
|
|
102
101
|
### client
|
|
103
102
|
Is used to handle `setname` and `getname` requests. `setname` is used to change the logging namespace. On `getname` the server will respond with the current connection name, which has been set via `getname`.
|
|
104
103
|
|
|
105
|
-
### multi
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
### exec
|
|
109
|
-
Just a dummy, responds with `OK`.
|
|
104
|
+
### multi/exec
|
|
105
|
+
Multi/exec is fully integrated but only works with pipelines and will give a piped response. It will not respond until `exec` is called.
|
|
106
|
+
On `exec` the simulator responds with `OK` (for `multi`), `QUEUED` for every command and the real results as an array for `exec`.
|
|
110
107
|
|
|
111
108
|
### sadd
|
|
112
109
|
Just a dummy, always responds with `1`, which means we have added the item to the set.
|
|
@@ -295,18 +295,29 @@ class ObjectsInMemoryServer extends ObjectsInMemoryFileDB {
|
|
|
295
295
|
);
|
|
296
296
|
}
|
|
297
297
|
handler.sendBulk(responseId, scriptChecksum);
|
|
298
|
+
} else if (data[1].includes('-- REDLOCK SCRIPT')) {
|
|
299
|
+
// redlock scripts are currently not needed for Simulator
|
|
300
|
+
this.knownScripts[scriptChecksum] = { redlock: true };
|
|
301
|
+
if (this.settings.connection.enhancedLogging) {
|
|
302
|
+
this.log.silly(
|
|
303
|
+
`${namespaceLog} Register Func LUA Script: ${scriptChecksum} = ${JSON.stringify(
|
|
304
|
+
this.knownScripts[scriptChecksum]
|
|
305
|
+
)}`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
handler.sendBulk(responseId, scriptChecksum);
|
|
298
309
|
} else {
|
|
299
|
-
handler.sendError(responseId, new Error(
|
|
310
|
+
handler.sendError(responseId, new Error(`Unknown LUA script ${data[1]}`));
|
|
300
311
|
}
|
|
301
312
|
} else {
|
|
302
|
-
handler.sendError(responseId, new Error(
|
|
313
|
+
handler.sendError(responseId, new Error(`Unsupported Script command ${data[0]}`));
|
|
303
314
|
}
|
|
304
315
|
});
|
|
305
316
|
|
|
306
317
|
// Handle Redis "EVALSHA" request
|
|
307
318
|
handler.on('evalsha', (data, responseId) => {
|
|
308
319
|
if (!this.knownScripts[data[0]]) {
|
|
309
|
-
return void handler.sendError(responseId, new Error(
|
|
320
|
+
return void handler.sendError(responseId, new Error(`Unknown Script ${data[0]}`));
|
|
310
321
|
}
|
|
311
322
|
if (this.knownScripts[data[0]].design) {
|
|
312
323
|
const scriptDesign = this.knownScripts[data[0]].design;
|
|
@@ -354,8 +365,11 @@ class ObjectsInMemoryServer extends ObjectsInMemoryFileDB {
|
|
|
354
365
|
const res = objs.rows.map(obj => JSON.stringify(this.dataset[obj.value._id || obj.id]));
|
|
355
366
|
|
|
356
367
|
return void handler.sendArray(responseId, res);
|
|
368
|
+
} else if (this.knownScripts[data[0]].redlock) {
|
|
369
|
+
// just return a dummy
|
|
370
|
+
return void handler.sendArray(responseId, [0]);
|
|
357
371
|
} else {
|
|
358
|
-
handler.sendError(responseId, new Error(
|
|
372
|
+
handler.sendError(responseId, new Error(`Unknown LUA script eval call ${JSON.stringify(data)}`));
|
|
359
373
|
}
|
|
360
374
|
});
|
|
361
375
|
|
|
@@ -522,11 +536,17 @@ class ObjectsInMemoryServer extends ObjectsInMemoryFileDB {
|
|
|
522
536
|
handler.sendBufBulk(responseId, Buffer.from(fileData));
|
|
523
537
|
}
|
|
524
538
|
} else if (namespace === this.metaNamespace) {
|
|
525
|
-
|
|
526
|
-
if (
|
|
527
|
-
|
|
539
|
+
// special handling for the primaryHost
|
|
540
|
+
if (id === 'objects.primaryHost') {
|
|
541
|
+
// we are the server -> we are primary
|
|
542
|
+
handler.sendString(this.settings.hostname);
|
|
528
543
|
} else {
|
|
529
|
-
|
|
544
|
+
const result = this.getMeta(id);
|
|
545
|
+
if (result === undefined || result === null) {
|
|
546
|
+
handler.sendNull(responseId);
|
|
547
|
+
} else {
|
|
548
|
+
handler.sendBulk(responseId, result);
|
|
549
|
+
}
|
|
530
550
|
}
|
|
531
551
|
} else {
|
|
532
552
|
handler.sendError(
|
|
@@ -711,15 +731,6 @@ class ObjectsInMemoryServer extends ObjectsInMemoryFileDB {
|
|
|
711
731
|
return this._handleScanOrKeys(handler, data[0], responseId);
|
|
712
732
|
});
|
|
713
733
|
|
|
714
|
-
// MULTI/EXEC is never used with return values, thus we just answer with syntactic correct responses
|
|
715
|
-
handler.on('multi', (data, responseId) => {
|
|
716
|
-
return void handler.sendString(responseId, 'OK');
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
handler.on('exec', (data, reponseId) => {
|
|
720
|
-
return void handler.sendArray(reponseId, []);
|
|
721
|
-
});
|
|
722
|
-
|
|
723
734
|
// commands for redis SETS, just dummies
|
|
724
735
|
handler.on('sadd', (data, responseId) => {
|
|
725
736
|
return void handler.sendInteger(responseId, 1);
|
|
@@ -771,9 +782,22 @@ class ObjectsInMemoryServer extends ObjectsInMemoryFileDB {
|
|
|
771
782
|
}
|
|
772
783
|
});
|
|
773
784
|
|
|
785
|
+
// Handle Redis "SUBSCRIBE" ... currently mainly ignored
|
|
786
|
+
handler.on('subscribe', (data, responseId) => {
|
|
787
|
+
if (data[0].startsWith('__keyevent@')) {
|
|
788
|
+
// we ignore these type of events because we publish expires anyway directly
|
|
789
|
+
handler.sendArray(responseId, ['subscribe', data[0], 1]);
|
|
790
|
+
} else {
|
|
791
|
+
handler.sendError(responseId, new Error(`SUBSCRIBE-UNSUPPORTED for ${data[0]}`));
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
|
|
774
795
|
// Handle Redis "CONFIG" ... currently mainly ignored
|
|
775
796
|
handler.on('config', (data, responseId) => {
|
|
776
|
-
if (data[0] === 'set' && data[1] === '
|
|
797
|
+
if (data[0] === 'set' && data[1] === 'notify-keyspace-events') {
|
|
798
|
+
// we ignore these type of commands for now, should only be to subscribe to keyspace events
|
|
799
|
+
handler.sendString(responseId, 'OK');
|
|
800
|
+
} else if (data[0] === 'set' && data[1] === 'lua-time-limit') {
|
|
777
801
|
// we ignore these type of commands for now, irrelevant
|
|
778
802
|
handler.sendString(responseId, 'OK');
|
|
779
803
|
} else {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/db-objects-file",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.49-20220121-e7aa4308",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=12.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@iobroker/db-base": "4.0.0-alpha.
|
|
9
|
-
"@iobroker/db-objects-redis": "4.0.0-alpha.
|
|
8
|
+
"@iobroker/db-base": "4.0.0-alpha.49-20220121-e7aa4308",
|
|
9
|
+
"@iobroker/db-objects-redis": "4.0.0-alpha.49-20220121-e7aa4308",
|
|
10
10
|
"deep-clone": "^3.0.3",
|
|
11
11
|
"fs-extra": "^10.0.0"
|
|
12
12
|
},
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"lib/",
|
|
36
36
|
"index.js"
|
|
37
37
|
],
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f42f117b74d3c4bfac0bc872c087d382ca897b7c"
|
|
39
39
|
}
|