@muze-nl/simplystore 0.3.5 → 0.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muze-nl/simplystore",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "main": "src/server.mjs",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/commands.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  export default {
2
2
  addPerson: (dataspace, command) => {
3
+ console.log('dataspace',dataspace)
3
4
  dataspace.persons.push(command.value)
4
5
  // dataspace.persons[0].name = 'Jan';
5
6
  return 'foo'
package/src/server.mjs CHANGED
@@ -37,7 +37,7 @@ async function main(options) {
37
37
 
38
38
  let queryWorkerpool = initWorkerPool(queryWorker)
39
39
 
40
- // const commandWorkerpool = initWorkerPool(commandWorker,1) // only one update worker so no changes can get lost
40
+ const commandWorkerpool = initWorkerPool(commandWorker,1) // only one update worker so no changes can get lost
41
41
 
42
42
  server.get('/', (req,res) => {
43
43
  res.send('<h1>SimplyStore</h1>') //@TODO: implement something nice
@@ -224,8 +224,8 @@ async function main(options) {
224
224
  let dataspace = JSONTag.parse(jsontag)
225
225
  //@TODO: make sure queryWorkerpool is only replaced after
226
226
  //workers are initialized, to prevent hickups if initialization takes a long time
227
- let newQueryWorkerpool = initWorkerPool('./worker-query')
228
- queryWorkerpool.terminate() // gracefully
227
+ let newQueryWorkerpool = initWorkerPool(queryWorker)
228
+ queryWorkerpool.destroy() // gracefully
229
229
  queryWorkerpool = newQueryWorkerpool
230
230
  //@TODO: write dataspace to disk
231
231
  status.set(command.id, 'done')
@@ -1,10 +1,11 @@
1
1
  import * as commandWorker from './worker-command.mjs'
2
2
  import worker_threads from 'node:worker_threads'
3
+ import JSONTag from '@muze-nl/jsontag'
3
4
 
4
5
  async function initialize() {
5
6
  let meta = {}
6
7
  let dataspace = JSONTag.parse(worker_threads.workerData, null, meta)
7
- await commandWorker.initialize(worker_threads.workerData)
8
+ await commandWorker.initialize(dataspace,meta)
8
9
  return commandWorker.runCommand
9
10
  }
10
11
 
@@ -7,7 +7,7 @@ import commands from './commands.mjs'
7
7
  * and type+attribute data gets lost
8
8
  */
9
9
 
10
- let dataspace
10
+ let dataspace, meta
11
11
 
12
12
  export function setDataspace(d) {
13
13
  dataspace = d
@@ -19,10 +19,10 @@ export function setDataspace(d) {
19
19
  * @TODO: setTimeout or do above checks in server.mjs before queueing
20
20
  */
21
21
 
22
- export function async initialize(jsontag) {
22
+ export async function initialize(jsontag, m) {
23
23
  if (!jsontag) { throw new Error('missing jsontag parameter')}
24
24
  dataspace = jsontag
25
- console.log('initialized command worker thread')
25
+ meta = m
26
26
  return true
27
27
  }
28
28