@twin.org/entity-storage-connector-memory 0.0.3-next.8 → 0.9.0-next.1

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.
@@ -1,6 +1,14 @@
1
1
  # Class: MemoryEntityStorageConnector\<T\>
2
2
 
3
- Class for performing entity storage operations in-memory.
3
+ Class for performing entity storage operations in-memory backed by a shared object buffer.
4
+
5
+ All reads and writes are serialised with a per-schema lock so that concurrent async
6
+ access, including across worker threads, never produces torn or lost updates.
7
+
8
+ All connector instances that share the same entity schema name share the same underlying
9
+ buffer, making data written in one instance immediately visible in another, including
10
+ across worker threads when the main thread forwards worker messages to the lock and
11
+ buffer handlers.
4
12
 
5
13
  ## Type Parameters
6
14
 
@@ -11,6 +19,7 @@ Class for performing entity storage operations in-memory.
11
19
  ## Implements
12
20
 
13
21
  - `IEntityStorageConnector`\<`T`\>
22
+ - `IEntityStorageMigrationConnector`\<`T`\>
14
23
 
15
24
  ## Constructors
16
25
 
@@ -60,6 +69,24 @@ The class name of the component.
60
69
 
61
70
  ***
62
71
 
72
+ ### health() {#health}
73
+
74
+ > **health**(): `Promise`\<`IHealth`[]\>
75
+
76
+ Returns the health status of the component.
77
+
78
+ #### Returns
79
+
80
+ `Promise`\<`IHealth`[]\>
81
+
82
+ The health status of the component.
83
+
84
+ #### Implementation of
85
+
86
+ `IEntityStorageConnector.health`
87
+
88
+ ***
89
+
63
90
  ### getSchema() {#getschema}
64
91
 
65
92
  > **getSchema**(): `IEntitySchema`
@@ -78,6 +105,32 @@ The schema for the entities.
78
105
 
79
106
  ***
80
107
 
108
+ ### bootstrap() {#bootstrap}
109
+
110
+ > **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
111
+
112
+ Bootstrap the component by creating and initializing any resources it needs.
113
+
114
+ #### Parameters
115
+
116
+ ##### nodeLoggingComponentType?
117
+
118
+ `string`
119
+
120
+ The node logging component type.
121
+
122
+ #### Returns
123
+
124
+ `Promise`\<`boolean`\>
125
+
126
+ True if the bootstrapping process was successful.
127
+
128
+ #### Implementation of
129
+
130
+ `IEntityStorageConnector.bootstrap`
131
+
132
+ ***
133
+
81
134
  ### get() {#get}
82
135
 
83
136
  > **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`T` \| `undefined`\>
@@ -140,7 +193,7 @@ The optional conditions to match for the entities.
140
193
 
141
194
  `Promise`\<`void`\>
142
195
 
143
- The id of the entity.
196
+ Resolves when the entity has been stored.
144
197
 
145
198
  #### Implementation of
146
199
 
@@ -148,6 +201,32 @@ The id of the entity.
148
201
 
149
202
  ***
150
203
 
204
+ ### setBatch() {#setbatch}
205
+
206
+ > **setBatch**(`entities`): `Promise`\<`void`\>
207
+
208
+ Set multiple entities in a batch.
209
+
210
+ #### Parameters
211
+
212
+ ##### entities
213
+
214
+ `T`[]
215
+
216
+ The entities to set.
217
+
218
+ #### Returns
219
+
220
+ `Promise`\<`void`\>
221
+
222
+ Nothing.
223
+
224
+ #### Implementation of
225
+
226
+ `IEntityStorageConnector.setBatch`
227
+
228
+ ***
229
+
151
230
  ### remove() {#remove}
152
231
 
153
232
  > **remove**(`id`, `conditions?`): `Promise`\<`void`\>
@@ -231,14 +310,248 @@ and a cursor which can be used to request more entities.
231
310
 
232
311
  ***
233
312
 
313
+ ### empty() {#empty}
314
+
315
+ > **empty**(): `Promise`\<`void`\>
316
+
317
+ Remove all entities from the storage.
318
+
319
+ #### Returns
320
+
321
+ `Promise`\<`void`\>
322
+
323
+ Nothing.
324
+
325
+ #### Implementation of
326
+
327
+ `IEntityStorageConnector.empty`
328
+
329
+ ***
330
+
331
+ ### removeBatch() {#removebatch}
332
+
333
+ > **removeBatch**(`ids`): `Promise`\<`void`\>
334
+
335
+ Remove multiple entities by id.
336
+
337
+ #### Parameters
338
+
339
+ ##### ids
340
+
341
+ `string`[]
342
+
343
+ The ids of the entities to remove.
344
+
345
+ #### Returns
346
+
347
+ `Promise`\<`void`\>
348
+
349
+ Nothing.
350
+
351
+ #### Implementation of
352
+
353
+ `IEntityStorageConnector.removeBatch`
354
+
355
+ ***
356
+
357
+ ### teardown() {#teardown}
358
+
359
+ > **teardown**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
360
+
361
+ Teardown the storage by clearing the underlying shared buffer for this schema.
362
+
363
+ #### Parameters
364
+
365
+ ##### nodeLoggingComponentType?
366
+
367
+ `string`
368
+
369
+ The node logging component type.
370
+
371
+ #### Returns
372
+
373
+ `Promise`\<`boolean`\>
374
+
375
+ True if the teardown process was successful.
376
+
377
+ #### Implementation of
378
+
379
+ `IEntityStorageConnector.teardown`
380
+
381
+ ***
382
+
383
+ ### count() {#count}
384
+
385
+ > **count**(`conditions?`): `Promise`\<`number`\>
386
+
387
+ Count all the entities which match the conditions.
388
+
389
+ #### Parameters
390
+
391
+ ##### conditions?
392
+
393
+ `EntityCondition`\<`T`\>
394
+
395
+ The optional conditions to match for the entities.
396
+
397
+ #### Returns
398
+
399
+ `Promise`\<`number`\>
400
+
401
+ The total count of entities in the storage.
402
+
403
+ #### Implementation of
404
+
405
+ `IEntityStorageConnector.count`
406
+
407
+ ***
408
+
234
409
  ### getStore() {#getstore}
235
410
 
236
- > **getStore**(): `T`[]
411
+ > **getStore**(): `Promise`\<`T`[]\>
237
412
 
238
- Get the memory store.
413
+ Get all entities in the memory store.
239
414
 
240
415
  #### Returns
241
416
 
242
- `T`[]
417
+ `Promise`\<`T`[]\>
418
+
419
+ All stored entities with partition keys removed.
420
+
421
+ ***
422
+
423
+ ### getPartitionContextIds() {#getpartitioncontextids}
424
+
425
+ > **getPartitionContextIds**(): `Promise`\<`IContextIds`[]\>
426
+
427
+ Get a unique list of all the context ids from the storage.
428
+
429
+ #### Returns
430
+
431
+ `Promise`\<`IContextIds`[]\>
432
+
433
+ The list of unique context ids.
434
+
435
+ #### Implementation of
436
+
437
+ `IEntityStorageMigrationConnector.getPartitionContextIds`
438
+
439
+ ***
440
+
441
+ ### createTargetConnector() {#createtargetconnector}
442
+
443
+ > **createTargetConnector**\<`U`\>(`newEntitySchema`): `Promise`\<`IEntityStorageConnector`\<`U`\>\>
444
+
445
+ Create the target connector for performing the migration it will use a temporary storage location.
446
+
447
+ #### Type Parameters
448
+
449
+ ##### U
450
+
451
+ `U`
452
+
453
+ #### Parameters
454
+
455
+ ##### newEntitySchema
456
+
457
+ `string`
458
+
459
+ The name of the new entity schema to create the connector for.
460
+
461
+ #### Returns
462
+
463
+ `Promise`\<`IEntityStorageConnector`\<`U`\>\>
464
+
465
+ Connector for performing the migration.
466
+
467
+ #### Implementation of
468
+
469
+ `IEntityStorageMigrationConnector.createTargetConnector`
470
+
471
+ ***
472
+
473
+ ### finalizeMigration() {#finalizemigration}
474
+
475
+ > **finalizeMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`IEntityStorageConnector`\<`U`\>\>
476
+
477
+ Finalize the migration by tearing down the old connector and replacing it with the target connector.
478
+
479
+ #### Type Parameters
480
+
481
+ ##### U
482
+
483
+ `U`
484
+
485
+ #### Parameters
486
+
487
+ ##### targetConnector
488
+
489
+ `IEntityStorageConnector`\<`U`\>
490
+
491
+ The target connector to finalize the migration with.
492
+
493
+ ##### options?
494
+
495
+ `IMigrationOptions`
496
+
497
+ The options to control how the migration is finalized.
498
+
499
+ ##### loggingComponentType?
500
+
501
+ `string`
502
+
503
+ The optional component type to use for logging the migration progress.
504
+
505
+ #### Returns
506
+
507
+ `Promise`\<`IEntityStorageConnector`\<`U`\>\>
508
+
509
+ A promise that resolves when the migration is finalized.
510
+
511
+ #### Implementation of
512
+
513
+ `IEntityStorageMigrationConnector.finalizeMigration`
514
+
515
+ ***
516
+
517
+ ### cleanupMigration() {#cleanupmigration}
518
+
519
+ > **cleanupMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`void`\>
520
+
521
+ Cleanup the migration if a migration fails or needs to be aborted.
522
+
523
+ #### Type Parameters
524
+
525
+ ##### U
526
+
527
+ `U`
528
+
529
+ #### Parameters
530
+
531
+ ##### targetConnector
532
+
533
+ `IEntityStorageConnector`\<`U`\> \| `undefined`
534
+
535
+ The target connector to cleanup the migration with.
536
+
537
+ ##### options?
538
+
539
+ `IMigrationOptions`
540
+
541
+ The options to control how the migration is cleaned up.
542
+
543
+ ##### loggingComponentType?
544
+
545
+ `string`
546
+
547
+ The optional component type to use for logging the migration progress.
548
+
549
+ #### Returns
550
+
551
+ `Promise`\<`void`\>
552
+
553
+ A promise that resolves when the migration is cleaned up.
554
+
555
+ #### Implementation of
243
556
 
244
- The store.
557
+ `IEntityStorageMigrationConnector.cleanupMigration`
@@ -6,4 +6,5 @@
6
6
 
7
7
  ## Interfaces
8
8
 
9
+ - [IMemoryEntityStorageConnectorConfig](interfaces/IMemoryEntityStorageConnectorConfig.md)
9
10
  - [IMemoryEntityStorageConnectorConstructorOptions](interfaces/IMemoryEntityStorageConnectorConstructorOptions.md)
@@ -0,0 +1,48 @@
1
+ # Interface: IMemoryEntityStorageConnectorConfig
2
+
3
+ Configuration for the Memory Entity Storage Connector.
4
+
5
+ ## Properties
6
+
7
+ ### storageKey {#storagekey}
8
+
9
+ > **storageKey**: `string`
10
+
11
+ Key to use for the shared buffer instead of the entity schema type.
12
+ Use this to give two connectors with the same entitySchema separate storage.
13
+
14
+ ***
15
+
16
+ ### initialCapacityBytes? {#initialcapacitybytes}
17
+
18
+ > `optional` **initialCapacityBytes?**: `number`
19
+
20
+ Initial capacity in bytes for the shared entity buffer.
21
+
22
+ #### Default
23
+
24
+ ```ts
25
+ 16 MiB.
26
+ ```
27
+
28
+ ***
29
+
30
+ ### maxCapacityBytes? {#maxcapacitybytes}
31
+
32
+ > `optional` **maxCapacityBytes?**: `number`
33
+
34
+ Maximum JSON payload size in bytes for the shared entity buffer.
35
+
36
+ #### Default
37
+
38
+ ```ts
39
+ 256 MiB.
40
+ ```
41
+
42
+ ***
43
+
44
+ ### mutexTimeoutMs? {#mutextimeoutms}
45
+
46
+ > `optional` **mutexTimeoutMs?**: `number`
47
+
48
+ Maximum milliseconds to wait for the per-directory write lock before throwing.
@@ -17,3 +17,11 @@ The schema for the entity.
17
17
  > `optional` **partitionContextIds?**: `string`[]
18
18
 
19
19
  The keys to use from the context ids to create partitions.
20
+
21
+ ***
22
+
23
+ ### config {#config}
24
+
25
+ > **config**: [`IMemoryEntityStorageConnectorConfig`](IMemoryEntityStorageConnectorConfig.md)
26
+
27
+ Configuration for storage key and capacity settings.
package/locales/en.json CHANGED
@@ -1 +1,13 @@
1
- {}
1
+ {
2
+ "info": {
3
+ "memoryEntityStorageConnector": {
4
+ "storeTearingDown": "Tearing down entity storage",
5
+ "storeTornDown": "Entity storage torn down"
6
+ }
7
+ },
8
+ "health": {
9
+ "memoryEntityStorageConnector": {
10
+ "healthDescription": "Memory entity storage for \"{entityType}\" is always available"
11
+ }
12
+ }
13
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-memory",
3
- "version": "0.0.3-next.8",
3
+ "version": "0.9.0-next.1",
4
4
  "description": "In-memory connector for local development, testing and short-lived workloads.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/entity-storage.git",
7
+ "url": "git+https://github.com/iotaledger/twin-entity-storage.git",
8
8
  "directory": "packages/entity-storage-connector-memory"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,11 +14,12 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/context": "next",
18
- "@twin.org/core": "next",
19
- "@twin.org/entity": "next",
20
- "@twin.org/entity-storage-models": "0.0.3-next.8",
21
- "@twin.org/nameof": "next"
17
+ "@twin.org/context": "0.9.0-next.1",
18
+ "@twin.org/core": "0.9.0-next.1",
19
+ "@twin.org/entity": "0.9.0-next.1",
20
+ "@twin.org/entity-storage-models": "0.9.0-next.1",
21
+ "@twin.org/logging-models": "0.9.0-next.1",
22
+ "@twin.org/nameof": "0.9.0-next.1"
22
23
  },
23
24
  "main": "./dist/es/index.js",
24
25
  "types": "./dist/types/index.d.ts",
@@ -55,7 +56,7 @@
55
56
  "testing"
56
57
  ],
57
58
  "bugs": {
58
- "url": "git+https://github.com/twinfoundation/entity-storage/issues"
59
+ "url": "git+https://github.com/iotaledger/twin-entity-storage/issues"
59
60
  },
60
61
  "homepage": "https://twindev.org"
61
62
  }