Skip to content

Commit 683ba2d

Browse files
committed
system store - load from core - two steps publish - PR notes 3
Signed-off-by: Amit Prinz Setter <[email protected]>
1 parent 6da2dd7 commit 683ba2d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/api/server_inter_process_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
type: 'object',
1919
properties: {
2020
since: { idate: true },
21-
load_from_core_step: {
21+
load_source: {
2222
type: 'string',
2323
enum: ['DB', 'CORE']
2424
}

src/server/common_services/server_inter_process.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const server_rpc = require('../server_rpc');
1919
async function load_system_store(req) {
2020
await system_store.load(
2121
req?.rpc_params?.since,
22-
req?.rpc_params?.load_from_core_step.toUpperCase()
22+
req?.rpc_params?.load_source.toUpperCase()
2323
);
2424
}
2525

src/server/system_services/system_store.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,21 +417,21 @@ class SystemStore extends EventEmitter {
417417
}
418418
}
419419

420-
async load(since, load_from_core_step) {
420+
async load(since, load_source) {
421421
//if endpoints load from core, and this load is for core
422-
//(ie, the first load_system_store() out of two with load_from_core_step === 'CORE'),
422+
//(ie, the first load_system_store() out of two with load_source === 'CORE'),
423423
//then endpoints skip it.
424424
//endpoints will be updated in the next load_system_store()
425425
//once core's in memory system store is updated.
426-
if (load_from_core_step && (this.source !== load_from_core_step)) {
426+
if (load_source && (this.source !== load_source)) {
427427
return;
428428
}
429429

430430
// serializing load requests since we have to run a fresh load after the previous one will finish
431431
// because it might not see the latest changes if we don't reload right after make_changes.
432432
return this._load_serial.surround(async () => {
433433
try {
434-
dbg.log3('SystemStore: loading ... this.last_update_time =', this.last_update_time, ", since =", since, "load_from_core_step =", load_from_core_step);
434+
dbg.log3('SystemStore: loading ... this.last_update_time =', this.last_update_time, ", since =", since, "load_source =", load_source);
435435

436436
// If we get a load request with an timestamp older then our last update time
437437
// we ensure we load everyting from that timestamp by updating our last_update_time.
@@ -687,7 +687,7 @@ class SystemStore extends EventEmitter {
687687
method_api: 'server_inter_process_api',
688688
method_name: 'load_system_store',
689689
target: '',
690-
request_params: { since: last_update, load_from_core_step: SOURCE.DB }
690+
request_params: { since: last_update, load_source: SOURCE.DB }
691691
});
692692

693693
//if endpoints are loading system store from core, we need to wait until
@@ -699,7 +699,7 @@ class SystemStore extends EventEmitter {
699699
method_api: 'server_inter_process_api',
700700
method_name: 'load_system_store',
701701
target: '',
702-
request_params: { since: last_update, load_from_core_step: SOURCE.CORE }
702+
request_params: { since: last_update, load_source: SOURCE.CORE }
703703
});
704704
}
705705
}

src/test/integration_tests/db/test_system_store.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const mocha = require('mocha');
55
const assert = require('assert');
66
const coretest = require('../../utils/coretest/coretest');
77
const db_client = require('../../../util/db_client');
8-
const { SystemStore } = require('../../../server/system_services/system_store');
8+
const { SystemStore, SOURCE } = require('../../../server/system_services/system_store');
99

1010
// setup coretest first to prepare the env
1111
coretest.setup();
@@ -142,12 +142,12 @@ mocha.describe('system_store', function() {
142142
mocha.it("Load from core", async function() {
143143

144144
const system_store_from_core = new SystemStore({
145-
source: 'CORE',
145+
source: SOURCE.CORE,
146146
skip_define_for_tests: true
147147
});
148148

149149
const from_db = await system_store.load();
150-
const from_core = await system_store_from_core.load(undefined, 'CORE');
150+
const from_core = await system_store_from_core.load(undefined, SOURCE.CORE);
151151

152152
assert.deepStrictEqual(from_db.data, from_core.data);
153153

0 commit comments

Comments
 (0)