@happyvertical/smrt-jobs 0.49.2 → 0.49.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/AGENTS.md +1 -1
- package/README.md +10 -1
- package/dist/chunks/{runner-BsYIDzhc.js → runner-DPSBS7Wf.js} +53 -17
- package/dist/chunks/{runner-BsYIDzhc.js.map → runner-DPSBS7Wf.js.map} +1 -1
- package/dist/durable-payload-integrity.d.ts +16 -0
- package/dist/durable-payload-integrity.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +391 -20
- package/dist/runner.d.ts +20 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +2 -2
- package/dist/smrt-knowledge.json +6 -6
- package/package.json +7 -7
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"timestamp": 0,
|
|
4
4
|
"packageName": "@happyvertical/smrt-jobs",
|
|
5
|
-
"packageVersion": "0.49.
|
|
5
|
+
"packageVersion": "0.49.4",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-jobs:ForgeDelivery": {
|
|
8
8
|
"name": "forgedelivery",
|
|
@@ -677,7 +677,7 @@
|
|
|
677
677
|
"collectionExportName": "ForgeDeliveryCollectionCollection",
|
|
678
678
|
"schema": {
|
|
679
679
|
"tableName": "_smrt_forge_deliveries",
|
|
680
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_forge_deliveries\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
680
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_forge_deliveries\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"provider\" TEXT NOT NULL,\n \"delivery_id\" TEXT NOT NULL,\n \"installation_key\" TEXT,\n \"repository_key\" TEXT,\n \"event_name\" TEXT NOT NULL,\n \"payload\" JSON,\n \"status\" TEXT NOT NULL DEFAULT 'pending',\n \"attempts\" INTEGER NOT NULL DEFAULT 0,\n \"max_attempts\" INTEGER NOT NULL DEFAULT 5,\n \"received_at\" TIMESTAMP NOT NULL,\n \"next_attempt_at\" TIMESTAMP NOT NULL,\n \"lease_owner\" TEXT,\n \"lease_token\" TEXT,\n \"lease_expires_at\" TIMESTAMP,\n \"last_error\" TEXT,\n \"completed_at\" TIMESTAMP,\n \"replay_count\" INTEGER NOT NULL DEFAULT 0\n);",
|
|
681
681
|
"columns": {
|
|
682
682
|
"id": {
|
|
683
683
|
"type": "UUID",
|
|
@@ -703,25 +703,143 @@
|
|
|
703
703
|
"type": "TIMESTAMP",
|
|
704
704
|
"notNull": true,
|
|
705
705
|
"default": "current_timestamp"
|
|
706
|
+
},
|
|
707
|
+
"tenant_id": {
|
|
708
|
+
"type": "UUID",
|
|
709
|
+
"referenceKind": "tenantId",
|
|
710
|
+
"notNull": true,
|
|
711
|
+
"unique": false
|
|
712
|
+
},
|
|
713
|
+
"provider": {
|
|
714
|
+
"type": "TEXT",
|
|
715
|
+
"notNull": true,
|
|
716
|
+
"unique": false
|
|
717
|
+
},
|
|
718
|
+
"delivery_id": {
|
|
719
|
+
"type": "TEXT",
|
|
720
|
+
"notNull": true,
|
|
721
|
+
"unique": false
|
|
722
|
+
},
|
|
723
|
+
"installation_key": {
|
|
724
|
+
"type": "TEXT",
|
|
725
|
+
"notNull": false,
|
|
726
|
+
"unique": false
|
|
727
|
+
},
|
|
728
|
+
"repository_key": {
|
|
729
|
+
"type": "TEXT",
|
|
730
|
+
"notNull": false,
|
|
731
|
+
"unique": false
|
|
732
|
+
},
|
|
733
|
+
"event_name": {
|
|
734
|
+
"type": "TEXT",
|
|
735
|
+
"notNull": true,
|
|
736
|
+
"unique": false
|
|
737
|
+
},
|
|
738
|
+
"payload": {
|
|
739
|
+
"type": "JSON",
|
|
740
|
+
"notNull": false,
|
|
741
|
+
"unique": false
|
|
742
|
+
},
|
|
743
|
+
"status": {
|
|
744
|
+
"type": "TEXT",
|
|
745
|
+
"notNull": true,
|
|
746
|
+
"unique": false,
|
|
747
|
+
"default": "pending"
|
|
748
|
+
},
|
|
749
|
+
"attempts": {
|
|
750
|
+
"type": "INTEGER",
|
|
751
|
+
"notNull": true,
|
|
752
|
+
"unique": false,
|
|
753
|
+
"default": 0
|
|
754
|
+
},
|
|
755
|
+
"max_attempts": {
|
|
756
|
+
"type": "INTEGER",
|
|
757
|
+
"notNull": true,
|
|
758
|
+
"unique": false,
|
|
759
|
+
"default": 5
|
|
760
|
+
},
|
|
761
|
+
"received_at": {
|
|
762
|
+
"type": "TIMESTAMP",
|
|
763
|
+
"notNull": true,
|
|
764
|
+
"unique": false
|
|
765
|
+
},
|
|
766
|
+
"next_attempt_at": {
|
|
767
|
+
"type": "TIMESTAMP",
|
|
768
|
+
"notNull": true,
|
|
769
|
+
"unique": false
|
|
770
|
+
},
|
|
771
|
+
"lease_owner": {
|
|
772
|
+
"type": "TEXT",
|
|
773
|
+
"notNull": false,
|
|
774
|
+
"unique": false
|
|
775
|
+
},
|
|
776
|
+
"lease_token": {
|
|
777
|
+
"type": "TEXT",
|
|
778
|
+
"notNull": false,
|
|
779
|
+
"unique": false
|
|
780
|
+
},
|
|
781
|
+
"lease_expires_at": {
|
|
782
|
+
"type": "TIMESTAMP",
|
|
783
|
+
"notNull": false,
|
|
784
|
+
"unique": false
|
|
785
|
+
},
|
|
786
|
+
"last_error": {
|
|
787
|
+
"type": "TEXT",
|
|
788
|
+
"notNull": false,
|
|
789
|
+
"unique": false
|
|
790
|
+
},
|
|
791
|
+
"completed_at": {
|
|
792
|
+
"type": "TIMESTAMP",
|
|
793
|
+
"notNull": false,
|
|
794
|
+
"unique": false
|
|
795
|
+
},
|
|
796
|
+
"replay_count": {
|
|
797
|
+
"type": "INTEGER",
|
|
798
|
+
"notNull": true,
|
|
799
|
+
"unique": false,
|
|
800
|
+
"default": 0
|
|
706
801
|
}
|
|
707
802
|
},
|
|
708
803
|
"indexes": [
|
|
804
|
+
{
|
|
805
|
+
"name": "_smrt_forge_deliveries_tenant_id_provider_idx",
|
|
806
|
+
"columns": [
|
|
807
|
+
"tenant_id",
|
|
808
|
+
"provider",
|
|
809
|
+
"delivery_id"
|
|
810
|
+
],
|
|
811
|
+
"unique": true
|
|
812
|
+
},
|
|
709
813
|
{
|
|
710
814
|
"name": "_smrt_forge_deliveries_slug_context_idx",
|
|
711
815
|
"columns": [
|
|
712
816
|
"slug",
|
|
713
817
|
"context"
|
|
714
|
-
]
|
|
715
|
-
"unique": true
|
|
818
|
+
]
|
|
716
819
|
},
|
|
717
820
|
{
|
|
718
|
-
"name": "
|
|
821
|
+
"name": "_smrt_forge_deliveries_status_next_attempt_at_idx",
|
|
822
|
+
"columns": [
|
|
823
|
+
"status",
|
|
824
|
+
"next_attempt_at"
|
|
825
|
+
]
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
"name": "_smrt_forge_deliveries_status_lease_expires_at_idx",
|
|
829
|
+
"columns": [
|
|
830
|
+
"status",
|
|
831
|
+
"lease_expires_at"
|
|
832
|
+
]
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
"name": "_smrt_forge_deliveries_tenant_id_created_at_idx",
|
|
719
836
|
"columns": [
|
|
837
|
+
"tenant_id",
|
|
720
838
|
"created_at"
|
|
721
839
|
]
|
|
722
840
|
}
|
|
723
841
|
],
|
|
724
|
-
"version": "
|
|
842
|
+
"version": "38d3f476"
|
|
725
843
|
}
|
|
726
844
|
},
|
|
727
845
|
"@happyvertical/smrt-jobs:SmrtJobEvent": {
|
|
@@ -957,7 +1075,8 @@
|
|
|
957
1075
|
"slug",
|
|
958
1076
|
"context"
|
|
959
1077
|
],
|
|
960
|
-
"unique": true
|
|
1078
|
+
"unique": true,
|
|
1079
|
+
"nullsNotDistinct": true
|
|
961
1080
|
},
|
|
962
1081
|
{
|
|
963
1082
|
"name": "_smrt_job_events_tenant_id_created_at_idx",
|
|
@@ -1093,7 +1212,7 @@
|
|
|
1093
1212
|
"collectionExportName": "SmrtJobEventCollectionCollection",
|
|
1094
1213
|
"schema": {
|
|
1095
1214
|
"tableName": "_smrt_job_events",
|
|
1096
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_job_events\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
1215
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_job_events\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"job_id\" UUID NOT NULL,\n \"type\" TEXT NOT NULL DEFAULT 'log',\n \"level\" TEXT NOT NULL DEFAULT 'info',\n \"stage\" TEXT,\n \"progress\" INTEGER,\n \"message\" TEXT NOT NULL DEFAULT '',\n \"data\" JSON\n);",
|
|
1097
1216
|
"columns": {
|
|
1098
1217
|
"id": {
|
|
1099
1218
|
"type": "UUID",
|
|
@@ -1119,25 +1238,79 @@
|
|
|
1119
1238
|
"type": "TIMESTAMP",
|
|
1120
1239
|
"notNull": true,
|
|
1121
1240
|
"default": "current_timestamp"
|
|
1241
|
+
},
|
|
1242
|
+
"tenant_id": {
|
|
1243
|
+
"type": "UUID",
|
|
1244
|
+
"referenceKind": "tenantId",
|
|
1245
|
+
"notNull": false,
|
|
1246
|
+
"unique": false
|
|
1247
|
+
},
|
|
1248
|
+
"job_id": {
|
|
1249
|
+
"type": "UUID",
|
|
1250
|
+
"referenceKind": "foreignKey",
|
|
1251
|
+
"notNull": true,
|
|
1252
|
+
"unique": false
|
|
1253
|
+
},
|
|
1254
|
+
"type": {
|
|
1255
|
+
"type": "TEXT",
|
|
1256
|
+
"notNull": true,
|
|
1257
|
+
"unique": false,
|
|
1258
|
+
"default": "log"
|
|
1259
|
+
},
|
|
1260
|
+
"level": {
|
|
1261
|
+
"type": "TEXT",
|
|
1262
|
+
"notNull": true,
|
|
1263
|
+
"unique": false,
|
|
1264
|
+
"default": "info"
|
|
1265
|
+
},
|
|
1266
|
+
"stage": {
|
|
1267
|
+
"type": "TEXT",
|
|
1268
|
+
"notNull": false,
|
|
1269
|
+
"unique": false
|
|
1270
|
+
},
|
|
1271
|
+
"progress": {
|
|
1272
|
+
"type": "INTEGER",
|
|
1273
|
+
"notNull": false,
|
|
1274
|
+
"unique": false
|
|
1275
|
+
},
|
|
1276
|
+
"message": {
|
|
1277
|
+
"type": "TEXT",
|
|
1278
|
+
"notNull": true,
|
|
1279
|
+
"unique": false,
|
|
1280
|
+
"default": ""
|
|
1281
|
+
},
|
|
1282
|
+
"data": {
|
|
1283
|
+
"type": "JSON",
|
|
1284
|
+
"notNull": false,
|
|
1285
|
+
"unique": false
|
|
1122
1286
|
}
|
|
1123
1287
|
},
|
|
1124
1288
|
"indexes": [
|
|
1125
1289
|
{
|
|
1126
1290
|
"name": "_smrt_job_events_slug_context_idx",
|
|
1127
1291
|
"columns": [
|
|
1292
|
+
"tenant_id",
|
|
1128
1293
|
"slug",
|
|
1129
1294
|
"context"
|
|
1130
1295
|
],
|
|
1131
|
-
"unique": true
|
|
1296
|
+
"unique": true,
|
|
1297
|
+
"nullsNotDistinct": true
|
|
1132
1298
|
},
|
|
1133
1299
|
{
|
|
1134
|
-
"name": "
|
|
1300
|
+
"name": "_smrt_job_events_tenant_id_created_at_idx",
|
|
1135
1301
|
"columns": [
|
|
1302
|
+
"tenant_id",
|
|
1136
1303
|
"created_at"
|
|
1137
1304
|
]
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
"name": "_smrt_job_events_job_id_idx",
|
|
1308
|
+
"columns": [
|
|
1309
|
+
"job_id"
|
|
1310
|
+
]
|
|
1138
1311
|
}
|
|
1139
1312
|
],
|
|
1140
|
-
"version": "
|
|
1313
|
+
"version": "8a9faeec"
|
|
1141
1314
|
}
|
|
1142
1315
|
},
|
|
1143
1316
|
"@happyvertical/smrt-jobs:SmrtJob": {
|
|
@@ -1640,7 +1813,8 @@
|
|
|
1640
1813
|
"slug",
|
|
1641
1814
|
"context"
|
|
1642
1815
|
],
|
|
1643
|
-
"unique": true
|
|
1816
|
+
"unique": true,
|
|
1817
|
+
"nullsNotDistinct": true
|
|
1644
1818
|
},
|
|
1645
1819
|
{
|
|
1646
1820
|
"name": "_smrt_jobs_run_at_idx",
|
|
@@ -1838,7 +2012,7 @@
|
|
|
1838
2012
|
"collectionExportName": "SmrtJobCollectionCollection",
|
|
1839
2013
|
"schema": {
|
|
1840
2014
|
"tableName": "_smrt_jobs",
|
|
1841
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_jobs\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
2015
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_jobs\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"queue\" TEXT NOT NULL DEFAULT 'default',\n \"object_type\" TEXT NOT NULL,\n \"object_id\" TEXT,\n \"method\" TEXT NOT NULL,\n \"args\" JSON,\n \"run_at\" TIMESTAMP NOT NULL,\n \"priority\" INTEGER NOT NULL DEFAULT 50,\n \"status\" TEXT NOT NULL DEFAULT 'pending',\n \"attempts\" INTEGER NOT NULL DEFAULT 0,\n \"max_attempts\" INTEGER NOT NULL DEFAULT 3,\n \"timeout\" INTEGER NOT NULL DEFAULT 300000,\n \"timeout_behavior\" TEXT NOT NULL DEFAULT 'fail',\n \"started_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"last_error\" TEXT,\n \"result_pointer\" TEXT,\n \"task_id\" TEXT UNIQUE,\n \"task_owner_id\" TEXT,\n \"task_result\" JSON,\n \"task_input_requests\" JSON,\n \"task_input_responses\" JSON,\n \"retry_strategy\" JSON,\n \"worker_id\" TEXT,\n \"worker_heartbeat\" TIMESTAMP\n);",
|
|
1842
2016
|
"columns": {
|
|
1843
2017
|
"id": {
|
|
1844
2018
|
"type": "UUID",
|
|
@@ -1864,25 +2038,180 @@
|
|
|
1864
2038
|
"type": "TIMESTAMP",
|
|
1865
2039
|
"notNull": true,
|
|
1866
2040
|
"default": "current_timestamp"
|
|
2041
|
+
},
|
|
2042
|
+
"tenant_id": {
|
|
2043
|
+
"type": "UUID",
|
|
2044
|
+
"referenceKind": "tenantId",
|
|
2045
|
+
"notNull": false,
|
|
2046
|
+
"unique": false
|
|
2047
|
+
},
|
|
2048
|
+
"queue": {
|
|
2049
|
+
"type": "TEXT",
|
|
2050
|
+
"notNull": true,
|
|
2051
|
+
"unique": false,
|
|
2052
|
+
"default": "default"
|
|
2053
|
+
},
|
|
2054
|
+
"object_type": {
|
|
2055
|
+
"type": "TEXT",
|
|
2056
|
+
"notNull": true,
|
|
2057
|
+
"unique": false
|
|
2058
|
+
},
|
|
2059
|
+
"object_id": {
|
|
2060
|
+
"type": "TEXT",
|
|
2061
|
+
"notNull": false,
|
|
2062
|
+
"unique": false
|
|
2063
|
+
},
|
|
2064
|
+
"method": {
|
|
2065
|
+
"type": "TEXT",
|
|
2066
|
+
"notNull": true,
|
|
2067
|
+
"unique": false
|
|
2068
|
+
},
|
|
2069
|
+
"args": {
|
|
2070
|
+
"type": "JSON",
|
|
2071
|
+
"notNull": false,
|
|
2072
|
+
"unique": false
|
|
2073
|
+
},
|
|
2074
|
+
"run_at": {
|
|
2075
|
+
"type": "TIMESTAMP",
|
|
2076
|
+
"notNull": true,
|
|
2077
|
+
"unique": false
|
|
2078
|
+
},
|
|
2079
|
+
"priority": {
|
|
2080
|
+
"type": "INTEGER",
|
|
2081
|
+
"notNull": true,
|
|
2082
|
+
"unique": false,
|
|
2083
|
+
"default": 50
|
|
2084
|
+
},
|
|
2085
|
+
"status": {
|
|
2086
|
+
"type": "TEXT",
|
|
2087
|
+
"notNull": true,
|
|
2088
|
+
"unique": false,
|
|
2089
|
+
"default": "pending"
|
|
2090
|
+
},
|
|
2091
|
+
"attempts": {
|
|
2092
|
+
"type": "INTEGER",
|
|
2093
|
+
"notNull": true,
|
|
2094
|
+
"unique": false,
|
|
2095
|
+
"default": 0
|
|
2096
|
+
},
|
|
2097
|
+
"max_attempts": {
|
|
2098
|
+
"type": "INTEGER",
|
|
2099
|
+
"notNull": true,
|
|
2100
|
+
"unique": false,
|
|
2101
|
+
"default": 3
|
|
2102
|
+
},
|
|
2103
|
+
"timeout": {
|
|
2104
|
+
"type": "INTEGER",
|
|
2105
|
+
"notNull": true,
|
|
2106
|
+
"unique": false,
|
|
2107
|
+
"default": 300000
|
|
2108
|
+
},
|
|
2109
|
+
"timeout_behavior": {
|
|
2110
|
+
"type": "TEXT",
|
|
2111
|
+
"notNull": true,
|
|
2112
|
+
"unique": false,
|
|
2113
|
+
"default": "fail"
|
|
2114
|
+
},
|
|
2115
|
+
"started_at": {
|
|
2116
|
+
"type": "TIMESTAMP",
|
|
2117
|
+
"notNull": false,
|
|
2118
|
+
"unique": false
|
|
2119
|
+
},
|
|
2120
|
+
"completed_at": {
|
|
2121
|
+
"type": "TIMESTAMP",
|
|
2122
|
+
"notNull": false,
|
|
2123
|
+
"unique": false
|
|
2124
|
+
},
|
|
2125
|
+
"last_error": {
|
|
2126
|
+
"type": "TEXT",
|
|
2127
|
+
"notNull": false,
|
|
2128
|
+
"unique": false
|
|
2129
|
+
},
|
|
2130
|
+
"result_pointer": {
|
|
2131
|
+
"type": "TEXT",
|
|
2132
|
+
"notNull": false,
|
|
2133
|
+
"unique": false
|
|
2134
|
+
},
|
|
2135
|
+
"task_id": {
|
|
2136
|
+
"type": "TEXT",
|
|
2137
|
+
"notNull": false,
|
|
2138
|
+
"unique": true
|
|
2139
|
+
},
|
|
2140
|
+
"task_owner_id": {
|
|
2141
|
+
"type": "TEXT",
|
|
2142
|
+
"notNull": false,
|
|
2143
|
+
"unique": false
|
|
2144
|
+
},
|
|
2145
|
+
"task_result": {
|
|
2146
|
+
"type": "JSON",
|
|
2147
|
+
"notNull": false,
|
|
2148
|
+
"unique": false
|
|
2149
|
+
},
|
|
2150
|
+
"task_input_requests": {
|
|
2151
|
+
"type": "JSON",
|
|
2152
|
+
"notNull": false,
|
|
2153
|
+
"unique": false
|
|
2154
|
+
},
|
|
2155
|
+
"task_input_responses": {
|
|
2156
|
+
"type": "JSON",
|
|
2157
|
+
"notNull": false,
|
|
2158
|
+
"unique": false
|
|
2159
|
+
},
|
|
2160
|
+
"retry_strategy": {
|
|
2161
|
+
"type": "JSON",
|
|
2162
|
+
"notNull": false,
|
|
2163
|
+
"unique": false
|
|
2164
|
+
},
|
|
2165
|
+
"worker_id": {
|
|
2166
|
+
"type": "TEXT",
|
|
2167
|
+
"notNull": false,
|
|
2168
|
+
"unique": false
|
|
2169
|
+
},
|
|
2170
|
+
"worker_heartbeat": {
|
|
2171
|
+
"type": "TIMESTAMP",
|
|
2172
|
+
"notNull": false,
|
|
2173
|
+
"unique": false
|
|
1867
2174
|
}
|
|
1868
2175
|
},
|
|
1869
2176
|
"indexes": [
|
|
1870
2177
|
{
|
|
1871
2178
|
"name": "_smrt_jobs_slug_context_idx",
|
|
1872
2179
|
"columns": [
|
|
2180
|
+
"tenant_id",
|
|
1873
2181
|
"slug",
|
|
1874
2182
|
"context"
|
|
1875
2183
|
],
|
|
1876
|
-
"unique": true
|
|
2184
|
+
"unique": true,
|
|
2185
|
+
"nullsNotDistinct": true
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
"name": "_smrt_jobs_run_at_idx",
|
|
2189
|
+
"columns": [
|
|
2190
|
+
"run_at"
|
|
2191
|
+
]
|
|
2192
|
+
},
|
|
2193
|
+
{
|
|
2194
|
+
"name": "_smrt_jobs_status_idx",
|
|
2195
|
+
"columns": [
|
|
2196
|
+
"status"
|
|
2197
|
+
]
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
"name": "_smrt_jobs_status_run_at_idx",
|
|
2201
|
+
"columns": [
|
|
2202
|
+
"status",
|
|
2203
|
+
"run_at"
|
|
2204
|
+
]
|
|
1877
2205
|
},
|
|
1878
2206
|
{
|
|
1879
|
-
"name": "
|
|
2207
|
+
"name": "_smrt_jobs_tenant_id_created_at_idx",
|
|
1880
2208
|
"columns": [
|
|
2209
|
+
"tenant_id",
|
|
1881
2210
|
"created_at"
|
|
1882
2211
|
]
|
|
1883
2212
|
}
|
|
1884
2213
|
],
|
|
1885
|
-
"version": "
|
|
2214
|
+
"version": "43e1324f"
|
|
1886
2215
|
}
|
|
1887
2216
|
},
|
|
1888
2217
|
"@happyvertical/smrt-jobs:SmrtWorker": {
|
|
@@ -2168,7 +2497,7 @@
|
|
|
2168
2497
|
"collectionExportName": "SmrtWorkerCollectionCollection",
|
|
2169
2498
|
"schema": {
|
|
2170
2499
|
"tableName": "_smrt_workers",
|
|
2171
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_workers\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
2500
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"_smrt_workers\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"worker_id\" TEXT NOT NULL,\n \"pid\" INTEGER,\n \"hostname\" TEXT,\n \"started_at\" TIMESTAMP,\n \"heartbeat_at\" TIMESTAMP,\n \"lease_expires_at\" TIMESTAMP,\n \"status\" TEXT NOT NULL DEFAULT 'running'\n);",
|
|
2172
2501
|
"columns": {
|
|
2173
2502
|
"id": {
|
|
2174
2503
|
"type": "UUID",
|
|
@@ -2194,16 +2523,58 @@
|
|
|
2194
2523
|
"type": "TIMESTAMP",
|
|
2195
2524
|
"notNull": true,
|
|
2196
2525
|
"default": "current_timestamp"
|
|
2526
|
+
},
|
|
2527
|
+
"worker_id": {
|
|
2528
|
+
"type": "TEXT",
|
|
2529
|
+
"notNull": true,
|
|
2530
|
+
"unique": false
|
|
2531
|
+
},
|
|
2532
|
+
"pid": {
|
|
2533
|
+
"type": "INTEGER",
|
|
2534
|
+
"notNull": false,
|
|
2535
|
+
"unique": false
|
|
2536
|
+
},
|
|
2537
|
+
"hostname": {
|
|
2538
|
+
"type": "TEXT",
|
|
2539
|
+
"notNull": false,
|
|
2540
|
+
"unique": false
|
|
2541
|
+
},
|
|
2542
|
+
"started_at": {
|
|
2543
|
+
"type": "TIMESTAMP",
|
|
2544
|
+
"notNull": false,
|
|
2545
|
+
"unique": false
|
|
2546
|
+
},
|
|
2547
|
+
"heartbeat_at": {
|
|
2548
|
+
"type": "TIMESTAMP",
|
|
2549
|
+
"notNull": false,
|
|
2550
|
+
"unique": false
|
|
2551
|
+
},
|
|
2552
|
+
"lease_expires_at": {
|
|
2553
|
+
"type": "TIMESTAMP",
|
|
2554
|
+
"notNull": false,
|
|
2555
|
+
"unique": false
|
|
2556
|
+
},
|
|
2557
|
+
"status": {
|
|
2558
|
+
"type": "TEXT",
|
|
2559
|
+
"notNull": true,
|
|
2560
|
+
"unique": false,
|
|
2561
|
+
"default": "running"
|
|
2197
2562
|
}
|
|
2198
2563
|
},
|
|
2199
2564
|
"indexes": [
|
|
2565
|
+
{
|
|
2566
|
+
"name": "_smrt_workers_worker_id_idx",
|
|
2567
|
+
"columns": [
|
|
2568
|
+
"worker_id"
|
|
2569
|
+
],
|
|
2570
|
+
"unique": true
|
|
2571
|
+
},
|
|
2200
2572
|
{
|
|
2201
2573
|
"name": "_smrt_workers_slug_context_idx",
|
|
2202
2574
|
"columns": [
|
|
2203
2575
|
"slug",
|
|
2204
2576
|
"context"
|
|
2205
|
-
]
|
|
2206
|
-
"unique": true
|
|
2577
|
+
]
|
|
2207
2578
|
},
|
|
2208
2579
|
{
|
|
2209
2580
|
"name": "_smrt_workers_created_at_idx",
|
|
@@ -2212,7 +2583,7 @@
|
|
|
2212
2583
|
]
|
|
2213
2584
|
}
|
|
2214
2585
|
],
|
|
2215
|
-
"version": "
|
|
2586
|
+
"version": "bfaad669"
|
|
2216
2587
|
}
|
|
2217
2588
|
}
|
|
2218
2589
|
},
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { DatabaseInterface } from '@happyvertical/sql';
|
|
3
|
+
import { JobExecutionContext } from './logger-extension.js';
|
|
3
4
|
import { RetentionSweeperOptions } from './retention.js';
|
|
4
5
|
import { SmrtJob } from './smrt-job.js';
|
|
5
6
|
import { SmrtJobEvent } from './smrt-job-event.js';
|
|
7
|
+
/** True only for an execution context constructed by this TaskRunner module. */
|
|
8
|
+
export declare function isRunnerExecutionContext(value: unknown): value is JobExecutionContext;
|
|
9
|
+
/** The runner-owned context for the currently executing task, if any. */
|
|
10
|
+
export declare function getActiveJobExecutionContext(): JobExecutionContext | undefined;
|
|
6
11
|
/**
|
|
7
12
|
* TaskRunner configuration
|
|
8
13
|
*/
|
|
@@ -13,8 +18,17 @@ export interface TaskRunnerConfig {
|
|
|
13
18
|
concurrency?: number;
|
|
14
19
|
/** Queues to process (default: ['default']) */
|
|
15
20
|
queues?: string[];
|
|
16
|
-
/**
|
|
21
|
+
/** Base polling interval in milliseconds, capped at the effective lease TTL. */
|
|
17
22
|
pollInterval?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Longest delay between empty queue checks in milliseconds.
|
|
25
|
+
*
|
|
26
|
+
* Empty checks back off exponentially from {@link pollInterval} to this
|
|
27
|
+
* value. Leave unset to cap idle checks at twenty times `pollInterval`.
|
|
28
|
+
* Every delay is bounded by the effective worker lease TTL (plus query and
|
|
29
|
+
* event-loop time), including a base interval larger than that TTL.
|
|
30
|
+
*/
|
|
31
|
+
idlePollInterval?: number;
|
|
18
32
|
/** Heartbeat interval in milliseconds */
|
|
19
33
|
heartbeatInterval?: number;
|
|
20
34
|
/** Maximum time to wait for jobs to complete on shutdown */
|
|
@@ -88,6 +102,7 @@ export declare class TaskRunner extends EventEmitter {
|
|
|
88
102
|
*/
|
|
89
103
|
private readonly workerKey;
|
|
90
104
|
private readonly config;
|
|
105
|
+
private readonly maxIdlePollIntervalMs;
|
|
91
106
|
private readonly effectiveLeaseTtlMs;
|
|
92
107
|
private collection;
|
|
93
108
|
private eventCollection;
|
|
@@ -97,6 +112,7 @@ export declare class TaskRunner extends EventEmitter {
|
|
|
97
112
|
private running;
|
|
98
113
|
private activeJobs;
|
|
99
114
|
private pollTimer;
|
|
115
|
+
private idlePollDelayMs;
|
|
100
116
|
private heartbeatTimer;
|
|
101
117
|
private leaseTimer;
|
|
102
118
|
/** Periodic system-table retention sweep, when not opted out (#2375). */
|
|
@@ -133,6 +149,9 @@ export declare class TaskRunner extends EventEmitter {
|
|
|
133
149
|
/**
|
|
134
150
|
* Poll for and process jobs
|
|
135
151
|
*/
|
|
152
|
+
private nextPollDelay;
|
|
153
|
+
private boundPollDelay;
|
|
154
|
+
private resetIdlePollDelay;
|
|
136
155
|
private poll;
|
|
137
156
|
/**
|
|
138
157
|
* Process a single job.
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAC;AAGhC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAY3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,EAGL,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,YAAY,EAA0B,MAAM,qBAAqB,CAAC;AAyBhF,gFAAgF;AAChF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,mBAAmB,CAM9B;AAED,yEAAyE;AACzE,wBAAgB,4BAA4B,IACxC,mBAAmB,GACnB,SAAS,CAEZ;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,WAAW,CA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pB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,kBAAkB;YAIZ,IAAI;IAsClB;;;;;;;;;;;;;OAaG;YACW,UAAU;IAwExB;;;;;;;;;;;;;;;OAeG;YACW,cAAc;IAqC5B;;;;;;;OAOG;YACW,aAAa;IAuB3B;;OAEG;YACW,UAAU;IAqKxB;;OAEG;YACW,cAAc;IAgF5B,OAAO,CAAC,sBAAsB;YAmEhB,cAAc;IA0C5B;;;OAGG;YACW,iBAAiB;IAO/B;;;;;;;;;;;;;OAaG;YACW,gBAAgB;IAiG9B;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAazB;;;;;OAKG;YACW,mBAAmB;IA+EjC,OAAO,CAAC,wBAAwB;IAQhC,2EAA2E;YAC7D,kBAAkB;IA8BhC;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAqBtB;;OAEG;YACW,iBAAiB;CAqBhC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAEtE;AAED,eAAe,UAAU,CAAC"}
|
package/dist/runner.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TaskRunner, r as createTaskRunner, t as JobTimeoutError } from "./chunks/runner-
|
|
2
|
-
export { JobTimeoutError, TaskRunner, TaskRunner as default, createTaskRunner };
|
|
1
|
+
import { a as isRunnerExecutionContext, i as getActiveJobExecutionContext, n as TaskRunner, r as createTaskRunner, t as JobTimeoutError } from "./chunks/runner-DPSBS7Wf.js";
|
|
2
|
+
export { JobTimeoutError, TaskRunner, TaskRunner as default, createTaskRunner, getActiveJobExecutionContext, isRunnerExecutionContext };
|