Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions acs-directory/lib/mqttcli.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,6 @@ export default class MQTTCli {

if (notify.length)
this.publish_changed(notify);

/* Clean up old sessions now we've finished the change-notify.
* Only do this for the current session; the old session's
* notify will also fire but we skip it here. */
if (session.next_for_device == null)
await this.model.cleanup_old_sessions(id);
}

async on_service_notify(id) {
Expand Down Expand Up @@ -452,7 +446,7 @@ export default class MQTTCli {

async on_birth(address, payload) {
this.log("device", `Registering BIRTH for ${address}`);
this.online.add(address.toString());
this.online.add(address);

let tree;
if (payload.uuid === UUIDs.FactoryPlus) {
Expand Down Expand Up @@ -485,7 +479,7 @@ export default class MQTTCli {
this.log("device", `Registering DEATH for ${address}`);

this.alerts.delete(address);
this.online.delete(address.toString());
this.online.delete(address);
await this.model.death({address, time});

this.log("device", `Finished DEATH for ${address}`);
Expand Down Expand Up @@ -552,7 +546,7 @@ export default class MQTTCli {
* rebirth any device we haven't seen a birth for, even if the
* database says it's online. This is important because we might
* have the wrong schema information. */
if (this.online.has(addr.toString()) || pending[addr]) return false;
if (this.online.has(addr) || pending[addr]) return false;

/* Mark that we're working on this device and wait 5-10s to see if
* it rebirths on its own. */
Expand All @@ -561,7 +555,7 @@ export default class MQTTCli {

/* Clear our marker first so we retry next time */
delete (pending[addr]);
if (this.online.has(addr.toString())) return false;
if (this.online.has(addr)) return false;

sent[addr] = Date.now();
return true;
Expand Down
8 changes: 0 additions & 8 deletions acs-directory/lib/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,6 @@ export default class Queries {
return dbr.rows.map(r => r.uuid);
}

async cleanup_old_sessions(session_id) {
await this.query(`
delete from session
where device = (select device from session where id = $1)
and next_for_device is not null
`, [session_id]);
}

async record_schema(session, schema) {
const schid = await this.find_or_create("schema", schema);
if (schid == null) return;
Expand Down
13 changes: 4 additions & 9 deletions acs-directory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,16 @@
"type": "module",
"scripts": {
"mqtt": "node bin/directory-mqtt",
"webapi": "node bin/directory-webapi",
"test": "vitest run"
"webapi": "node bin/directory-webapi"
},
"dependencies": {
"@amrc-factoryplus/pg-client": "file:../lib/js-pg-client",
"@amrc-factoryplus/rx-client": "file:../lib/js-rx-client",
"@amrc-factoryplus/rx-util": "file:../lib/js-rx-util",
"@amrc-factoryplus/service-api": "file:../lib/js-service-api",
"@amrc-factoryplus/service-client": "file:../lib/js-service-client",
"@amrc-factoryplus/service-api": "file:../lib/js-service-api",
"@amrc-factoryplus/pg-client": "file:../lib/js-pg-client",
"async": "^3.2.4",
"express": "^4.17.1",
"express-openapi-validator": "^4.13.2",
"long": "^5.3.2"
},
"devDependencies": {
"vitest": "^3.0.4"
"express-openapi-validator": "^4.13.2"
}
}
59 changes: 0 additions & 59 deletions acs-directory/test/find-schemas.test.js

This file was deleted.

38 changes: 0 additions & 38 deletions acs-directory/test/session-cleanup.test.js

This file was deleted.

7 changes: 0 additions & 7 deletions acs-directory/vitest.config.js

This file was deleted.

5 changes: 3 additions & 2 deletions lib/js-service-client/lib/sparkplug/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export class Address {
* @arg device Device ID
*/
constructor (group, node, device) {
if (device == null || device == "")
device = undefined;
this.group = group;
this.node = node;

if (device == null || device == "")
device = undefined;
this.device = device;
}

Expand Down
5 changes: 2 additions & 3 deletions lib/js-service-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"type": "module",
"scripts": {
"test": "vitest run"
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
Expand All @@ -26,7 +26,6 @@
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"eslint": "^9.13.0",
"globals": "^15.11.0",
"vitest": "^3.0.4"
"globals": "^15.11.0"
}
}
50 changes: 0 additions & 50 deletions lib/js-service-client/test/address.test.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/js-service-client/vitest.config.js

This file was deleted.

Loading