@superhero/eventflow-spoke 4.0.0 → 4.0.2
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 +7 -9
- package/config.js +6 -6
- package/index.js +44 -7
- package/index.test.js +6 -9
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -26,14 +26,12 @@ npm install @superhero/eventflow-spoke
|
|
|
26
26
|
To initialize a Spoke instance:
|
|
27
27
|
|
|
28
28
|
```javascript
|
|
29
|
-
import
|
|
30
|
-
|
|
29
|
+
import Locator from '@superhero/locator'
|
|
31
30
|
const locator = new Locator()
|
|
32
|
-
locator.
|
|
33
|
-
locator.
|
|
34
|
-
locator.eagerload(config.find('locator'))
|
|
35
|
-
|
|
36
|
-
const spoke = locate(locator)
|
|
31
|
+
await locator.config.add('@superhero/eventflow-db')
|
|
32
|
+
await locator.config.add('@superhero/eventflow-spoke')
|
|
33
|
+
await locator.eagerload(locator.config.find('locator'))
|
|
34
|
+
const spoke = locator('@superhero/eventflow-spoke')
|
|
37
35
|
await spoke.bootstrap()
|
|
38
36
|
```
|
|
39
37
|
|
|
@@ -210,7 +208,7 @@ file | line % | branch % | funcs % | uncovered lines
|
|
|
210
208
|
-------------------------------------------------------------------------------------------------------------------------
|
|
211
209
|
config.js | 100.00 | 100.00 | 100.00 |
|
|
212
210
|
consume.js | 42.24 | 100.00 | 42.86 | 43-55 58-91 94-103 106-115
|
|
213
|
-
index.js | 86.26 | 80.43 | 88.89 |
|
|
211
|
+
index.js | 86.26 | 80.43 | 88.89 | 35-37 45-48 101-105 112-113 119-122 145-160 180-184 206-211 220-232…
|
|
214
212
|
index.test.js | 100.00 | 100.00 | 100.00 |
|
|
215
213
|
manager | | | |
|
|
216
214
|
hubs.js | 100.00 | 100.00 | 100.00 |
|
|
@@ -218,7 +216,7 @@ manager | | | |
|
|
|
218
216
|
listeners.js | 100.00 | 100.00 | 88.89 |
|
|
219
217
|
listeners.test.js | 100.00 | 100.00 | 100.00 |
|
|
220
218
|
-------------------------------------------------------------------------------------------------------------------------
|
|
221
|
-
all files |
|
|
219
|
+
all files | 86.35 | 91.45 | 90.10 |
|
|
222
220
|
-------------------------------------------------------------------------------------------------------------------------
|
|
223
221
|
```
|
|
224
222
|
|
package/config.js
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export default
|
|
5
5
|
{
|
|
6
|
-
dependency:
|
|
7
|
-
{
|
|
8
|
-
'@superhero/eventflow-db' : '@superhero/eventflow-db'
|
|
9
|
-
},
|
|
10
6
|
bootstrap:
|
|
11
7
|
{
|
|
12
8
|
'@superhero/eventflow-spoke' : true,
|
|
13
9
|
'@superhero/eventflow-spoke/consume' : true
|
|
14
10
|
},
|
|
11
|
+
dependency:
|
|
12
|
+
{
|
|
13
|
+
'@superhero/eventflow-db' : true
|
|
14
|
+
},
|
|
15
15
|
locator:
|
|
16
16
|
{
|
|
17
|
-
'@superhero/eventflow-spoke' :
|
|
18
|
-
'@superhero/eventflow-spoke/consume' :
|
|
17
|
+
'@superhero/eventflow-spoke' : true,
|
|
18
|
+
'@superhero/eventflow-spoke/consume' : true
|
|
19
19
|
},
|
|
20
20
|
eventflow:
|
|
21
21
|
{
|
package/index.js
CHANGED
|
@@ -11,8 +11,8 @@ import ListenersManager from '@superhero/eventflow-spoke/manager/listeners
|
|
|
11
11
|
export function locate(locator)
|
|
12
12
|
{
|
|
13
13
|
const
|
|
14
|
-
config = locator
|
|
15
|
-
db = locator('@superhero/eventflow-db')
|
|
14
|
+
config = locator.config.find('eventflow/spoke'),
|
|
15
|
+
db = locator.locate('@superhero/eventflow-db')
|
|
16
16
|
|
|
17
17
|
return new Spoke(config, db)
|
|
18
18
|
}
|
|
@@ -24,11 +24,12 @@ export default class Spoke
|
|
|
24
24
|
{
|
|
25
25
|
#spokeID
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
idNameGenerator = new IdNameGenerator()
|
|
28
|
+
abortion = new AbortController()
|
|
29
|
+
channel = new Channel()
|
|
30
|
+
hubs = new HubsManager()
|
|
31
|
+
subscriptions = new ListenersManager()
|
|
32
|
+
consumers = new ListenersManager()
|
|
32
33
|
|
|
33
34
|
get spokeID()
|
|
34
35
|
{
|
|
@@ -307,12 +308,18 @@ export default class Spoke
|
|
|
307
308
|
})
|
|
308
309
|
}
|
|
309
310
|
|
|
311
|
+
generatePid()
|
|
312
|
+
{
|
|
313
|
+
return this.idNameGenerator.generateId()
|
|
314
|
+
}
|
|
315
|
+
|
|
310
316
|
async publish(event)
|
|
311
317
|
{
|
|
312
318
|
const eventID = await this.persist(event)
|
|
313
319
|
await this.db.persistEventPublished({ event_id:eventID, publisher:this.#spokeID })
|
|
314
320
|
this.#broadcast('publish', event.domain, eventID, event.name, event.pid)
|
|
315
321
|
this.log.info`published event ${eventID} › ${event.domain} › ${event.name} › ${event.pid}`
|
|
322
|
+
return eventID
|
|
316
323
|
}
|
|
317
324
|
|
|
318
325
|
async schedule(scheduled, event)
|
|
@@ -340,6 +347,16 @@ export default class Spoke
|
|
|
340
347
|
return await this.db.persistEvent(event)
|
|
341
348
|
}
|
|
342
349
|
|
|
350
|
+
async persistEntityAssociation(event_id, eid)
|
|
351
|
+
{
|
|
352
|
+
return await this.db.persistEventEid(event_id, eid)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async persistChildProcessAssociation(event_id, domain, cpid)
|
|
356
|
+
{
|
|
357
|
+
return await this.db.persistEventCpid(event_id, domain, cpid)
|
|
358
|
+
}
|
|
359
|
+
|
|
343
360
|
async delete(eventID)
|
|
344
361
|
{
|
|
345
362
|
return await this.db.deleteEvent(eventID)
|
|
@@ -360,6 +377,26 @@ export default class Spoke
|
|
|
360
377
|
return await this.db.readEventsByDomainAndPid(domain, pid)
|
|
361
378
|
}
|
|
362
379
|
|
|
380
|
+
async readEventlogFilteredByNames(domain, pid, names)
|
|
381
|
+
{
|
|
382
|
+
return await this.db.readEventsByDomainAndPidAndNames(domain, pid, names)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
async readEventlogByChildProcess(domain, cpid)
|
|
386
|
+
{
|
|
387
|
+
return await this.db.readEventsByDomainAndCpid(domain, cpid)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async readEventlogByEid(eid)
|
|
391
|
+
{
|
|
392
|
+
return await this.db.readEventsByEid(eid)
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
async readEventlogByDomainAndEid(domain, eid)
|
|
396
|
+
{
|
|
397
|
+
return await this.db.readEventsByDomainAndEid(domain, eid)
|
|
398
|
+
}
|
|
399
|
+
|
|
363
400
|
async readEventlogState(domain, pid)
|
|
364
401
|
{
|
|
365
402
|
const
|
package/index.test.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert/strict'
|
|
2
2
|
import util from 'node:util'
|
|
3
|
-
import Config from '@superhero/config'
|
|
4
3
|
import Locator from '@superhero/locator'
|
|
5
4
|
import { suite, test, before, after } from 'node:test'
|
|
6
5
|
|
|
@@ -14,16 +13,14 @@ suite('@superhero/eventflow-spoke', () =>
|
|
|
14
13
|
{
|
|
15
14
|
locator = new Locator()
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
await config.add('@superhero/eventflow-
|
|
19
|
-
await config.add('
|
|
20
|
-
|
|
21
|
-
config.assign({ eventflow: {
|
|
22
|
-
config.assign({ eventflow: { hub: { certificates: { CERT_PASS_ENCRYPTION_KEY: 'encryptionKey123' }}}})
|
|
16
|
+
await locator.config.add('@superhero/eventflow-db')
|
|
17
|
+
await locator.config.add('@superhero/eventflow-hub')
|
|
18
|
+
await locator.config.add('./config.js')
|
|
19
|
+
locator.config.assign({ eventflow: { spoke: { certificates: { CERT_PASS_ENCRYPTION_KEY: 'encryptionKey123' }}}})
|
|
20
|
+
locator.config.assign({ eventflow: { hub: { certificates: { CERT_PASS_ENCRYPTION_KEY: 'encryptionKey123' }}}})
|
|
23
21
|
|
|
24
|
-
locator.set('@superhero/config', config)
|
|
25
22
|
await locator.eagerload('@superhero/eventflow-db')
|
|
26
|
-
await locator.eagerload(config.find('locator'))
|
|
23
|
+
await locator.eagerload(locator.config.find('locator'))
|
|
27
24
|
|
|
28
25
|
spoke = locator('@superhero/eventflow-spoke')
|
|
29
26
|
hub = locator('@superhero/eventflow-hub')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/eventflow-spoke",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Eventflow spoke is the client component in the eventflow ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eventflow",
|
|
@@ -16,16 +16,15 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@superhero/deep": "^4.2.0",
|
|
19
|
-
"@superhero/eventflow-certificates": "^4.0.
|
|
20
|
-
"@superhero/eventflow-db": "^4.1
|
|
19
|
+
"@superhero/eventflow-certificates": "^4.0.5",
|
|
20
|
+
"@superhero/eventflow-db": "^4.2.1",
|
|
21
21
|
"@superhero/id-name-generator": "^4.0.0",
|
|
22
22
|
"@superhero/log": "^4.0.0",
|
|
23
23
|
"@superhero/tcp-record-channel": "^4.2.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@superhero/
|
|
27
|
-
"@superhero/
|
|
28
|
-
"@superhero/eventflow-hub": "^4.0.4"
|
|
26
|
+
"@superhero/locator": "^4.2.3",
|
|
27
|
+
"@superhero/eventflow-hub": "^4.0.6"
|
|
29
28
|
},
|
|
30
29
|
"scripts": {
|
|
31
30
|
"test-build": "npm explore @superhero/eventflow-db -- npm run test-build",
|