@superhero/eventflow-db 4.2.2 → 4.2.4

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/index.js CHANGED
@@ -261,7 +261,7 @@ export default class DB
261
261
  }
262
262
  catch(reason)
263
263
  {
264
- const error = new Error(`could not read event by pid: ${pid} and domain: ${domain}`)
264
+ const error = new Error(`could not read events by pid: ${pid} and domain: ${domain}`)
265
265
  error.code = 'E_EVENTFLOW_DB_EVENT_READ_BY_PID'
266
266
  error.cause = reason
267
267
  throw error
@@ -270,6 +270,25 @@ export default class DB
270
270
  return result
271
271
  }
272
272
 
273
+ async readEventsByDomainAndPidBetweenTimestamps(domain, pid, timestampMin, timestampMax)
274
+ {
275
+ let result
276
+
277
+ try
278
+ {
279
+ result = await this.gateway.query('event/read-by-pid-domain-betweeen-timestamps', [ pid, domain, timestampMin, timestampMax ])
280
+ }
281
+ catch(reason)
282
+ {
283
+ const error = new Error(`could not read events by pid: ${pid} and domain: ${domain}`)
284
+ error.code = 'E_EVENTFLOW_DB_EVENT_READ_BY_PID_BETWEEN_TIMESTAMPS'
285
+ error.cause = reason
286
+ throw error
287
+ }
288
+
289
+ return result
290
+ }
291
+
273
292
  async readEventsByDomainAndPidAndNames(domain, pid, names)
274
293
  {
275
294
  let result
@@ -280,7 +299,7 @@ export default class DB
280
299
  }
281
300
  catch(reason)
282
301
  {
283
- const error = new Error(`could not read event by pid: ${pid} and domain: ${domain}`)
302
+ const error = new Error(`could not read events by pid: ${pid} and domain: ${domain}`)
284
303
  error.code = 'E_EVENTFLOW_DB_EVENT_READ_BY_PID'
285
304
  error.cause = reason
286
305
  throw error
@@ -414,7 +433,7 @@ export default class DB
414
433
  }
415
434
  catch(reason)
416
435
  {
417
- const error = new Error(`could not read event by eid: ${eid}`)
436
+ const error = new Error(`could not read events by eid: ${eid}`)
418
437
  error.code = 'E_EVENTFLOW_DB_EVENTS_READ_BY_EID'
419
438
  error.cause = reason
420
439
  throw error
@@ -661,6 +680,22 @@ export default class DB
661
680
  }
662
681
  }
663
682
 
683
+ async hasHubQuit(hub)
684
+ {
685
+ try
686
+ {
687
+ const result = await this.gateway.query('hub/read-quit-hub', [ hub ])
688
+ return result.length > 0
689
+ }
690
+ catch(reason)
691
+ {
692
+ const error = new Error(`could not check if hub: ${hub} has quit`)
693
+ error.code = 'E_EVENTFLOW_DB_HUB_HAS_QUIT'
694
+ error.cause = reason
695
+ throw error
696
+ }
697
+ }
698
+
664
699
  async persistLog(log)
665
700
  {
666
701
  try
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/eventflow-db",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "description": "Eventflow db is a set of common database logic in the eventflow ecosystem.",
5
5
  "keywords": [
6
6
  "eventflow"
@@ -15,7 +15,7 @@
15
15
  "@superhero/db": "^0.5.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@superhero/locator": "4.2.4"
18
+ "@superhero/locator": "4.2.5"
19
19
  },
20
20
  "scripts": {
21
21
  "test-build": "docker ps -q -f name=eventflow-mysql | grep -q . && docker stop eventflow-mysql; docker run --rm --name eventflow-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=eventflow -p 3306:3306 --health-cmd=\"mysqladmin ping -h 127.0.0.1 -uroot -proot --silent || exit 1\" --health-interval=10s --health-timeout=5s --health-retries=5 -d mysql:latest; until [ \"$(docker inspect --format='{{.State.Health.Status}}' eventflow-mysql)\" == \"healthy\" ]; do sleep 1; done",
@@ -0,0 +1,6 @@
1
+ SELECT *
2
+ FROM event
3
+ WHERE pid = ?
4
+ AND domain = ?
5
+ AND timestamp BETWEEN ? AND ?
6
+ ORDER BY timestamp ASC
@@ -2,4 +2,5 @@ SELECT *
2
2
  FROM event
3
3
  WHERE pid = ?
4
4
  AND domain = ?
5
- AND name IN (?)
5
+ AND name IN (?)
6
+ ORDER BY timestamp ASC
@@ -2,3 +2,4 @@ SELECT *
2
2
  FROM event
3
3
  WHERE pid = ?
4
4
  AND domain = ?
5
+ ORDER BY timestamp ASC
@@ -3,4 +3,5 @@ FROM event_cpid
3
3
  JOIN event
4
4
  ON event_id = id AND event.domain = event_cpid.domain
5
5
  WHERE event_cpid.cpid = ?
6
- AND event_cpid.domain = ?
6
+ AND event_cpid.domain = ?
7
+ ORDER BY timestamp ASC
@@ -3,4 +3,5 @@ FROM event_eid
3
3
  JOIN event
4
4
  ON event_id = id
5
5
  WHERE eid = ?
6
- AND domain = ?
6
+ AND domain = ?
7
+ ORDER BY timestamp ASC
@@ -2,4 +2,5 @@ SELECT event.*
2
2
  FROM event_eid
3
3
  JOIN event
4
4
  ON event_id = id
5
- WHERE eid = ?
5
+ WHERE eid = ?
6
+ ORDER BY timestamp ASC
@@ -1,4 +1,5 @@
1
1
  SELECT *
2
2
  FROM event_scheduled
3
3
  WHERE scheduled >= UTC_TIMESTAMP()
4
- AND executed IS NULL
4
+ AND executed IS NULL
5
+ ORDER BY timestamp ASC
@@ -1,3 +1,4 @@
1
1
  SELECT *
2
2
  FROM hub
3
- WHERE quit IS NULL
3
+ WHERE quit IS NULL
4
+ ORDER BY timestamp ASC
@@ -0,0 +1,4 @@
1
+ SELECT *
2
+ FROM hub
3
+ WHERE id = ?
4
+ AND quit IS NOT NULL
@@ -1,3 +1,4 @@
1
1
  UPDATE hub
2
2
  SET quit = UTC_TIMESTAMP()
3
- WHERE id = ?
3
+ WHERE id = ?
4
+ AND quit IS NULL