@travetto/model 4.0.1 → 4.0.3
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": "@travetto/model",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Datastore abstraction for core operations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datastore",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"directory": "module/model"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^4.0.
|
|
30
|
-
"@travetto/di": "^4.0.
|
|
31
|
-
"@travetto/registry": "^4.0.
|
|
32
|
-
"@travetto/schema": "^4.0.
|
|
29
|
+
"@travetto/config": "^4.0.3",
|
|
30
|
+
"@travetto/di": "^4.0.3",
|
|
31
|
+
"@travetto/registry": "^4.0.3",
|
|
32
|
+
"@travetto/schema": "^4.0.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@travetto/cli": "^4.0.
|
|
36
|
-
"@travetto/test": "^4.0.
|
|
35
|
+
"@travetto/cli": "^4.0.4",
|
|
36
|
+
"@travetto/test": "^4.0.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { ShutdownManager, Class, TimeSpan, TimeUtil } from '@travetto/base';
|
|
1
|
+
import { ShutdownManager, Class, TimeSpan, TimeUtil, Util } from '@travetto/base';
|
|
4
2
|
|
|
5
3
|
import { ModelRegistry } from '../../registry/model';
|
|
6
4
|
import { ModelExpirySupport } from '../../service/expiry';
|
|
@@ -35,15 +33,15 @@ export class ModelExpiryUtil {
|
|
|
35
33
|
static registerCull(svc: ModelExpirySupport & { readonly config?: { cullRate?: number | TimeSpan } }): void {
|
|
36
34
|
const cullable = ModelRegistry.getClasses().filter(cls => !!ModelRegistry.get(cls).expiresAt);
|
|
37
35
|
if (svc.deleteExpired && cullable.length) {
|
|
38
|
-
|
|
36
|
+
const running = new AbortController();
|
|
39
37
|
const cullInterval = TimeUtil.timeToMs(svc.config?.cullRate ?? '10m');
|
|
40
38
|
|
|
41
|
-
ShutdownManager.onGracefulShutdown(async () =>
|
|
39
|
+
ShutdownManager.onGracefulShutdown(async () => running.abort(), this);
|
|
42
40
|
|
|
43
41
|
(async (): Promise<void> => {
|
|
44
|
-
await
|
|
45
|
-
while (running) {
|
|
46
|
-
await
|
|
42
|
+
await Util.nonBlockingTimeout(1000);
|
|
43
|
+
while (!running.signal.aborted) {
|
|
44
|
+
await Util.nonBlockingTimeout(cullInterval);
|
|
47
45
|
await Promise.all(cullable.map(cls => svc.deleteExpired(cls)));
|
|
48
46
|
}
|
|
49
47
|
})();
|