@cadenza.io/service 2.3.12 → 2.3.14
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/dist/index.js +35 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -178,6 +178,7 @@ var DeputyTask = class extends import_core.Task {
|
|
|
178
178
|
const ctx = context.getContext();
|
|
179
179
|
const metadata = context.getMetadata();
|
|
180
180
|
const deputyContext = {
|
|
181
|
+
__timeout: this.timeout,
|
|
181
182
|
__localTaskName: this.name,
|
|
182
183
|
__localTaskVersion: this.version,
|
|
183
184
|
__localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -560,8 +561,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
560
561
|
);
|
|
561
562
|
return joinedContext;
|
|
562
563
|
}
|
|
563
|
-
).then(this.handleGlobalSignalRegistrationTask);
|
|
564
|
+
).emits("meta.service_registry.initial_sync_complete").then(this.handleGlobalSignalRegistrationTask);
|
|
564
565
|
this.fullSyncTask = CadenzaService.createMetaRoutine("Full sync", [
|
|
566
|
+
CadenzaService.createTask("Confirm full sync", () => {
|
|
567
|
+
console.log("Confirming full sync...");
|
|
568
|
+
}),
|
|
565
569
|
CadenzaService.createCadenzaDBQueryTask("signal_to_task_map", {
|
|
566
570
|
filter: {
|
|
567
571
|
isGlobal: true
|
|
@@ -1947,7 +1951,7 @@ var SocketController = class _SocketController {
|
|
|
1947
1951
|
transports: ["websocket"],
|
|
1948
1952
|
autoConnect: false
|
|
1949
1953
|
});
|
|
1950
|
-
emitWhenReady = (event, data, timeoutMs =
|
|
1954
|
+
emitWhenReady = (event, data, timeoutMs = 6e4, ack) => {
|
|
1951
1955
|
return new Promise((resolve) => {
|
|
1952
1956
|
const tryEmit = () => {
|
|
1953
1957
|
if (!socket?.connected) {
|
|
@@ -1981,7 +1985,12 @@ var SocketController = class _SocketController {
|
|
|
1981
1985
|
if (err) {
|
|
1982
1986
|
CadenzaService.log(
|
|
1983
1987
|
"Socket timeout.",
|
|
1984
|
-
{
|
|
1988
|
+
{
|
|
1989
|
+
event,
|
|
1990
|
+
error: err.message,
|
|
1991
|
+
socketId: socket?.id,
|
|
1992
|
+
serviceName
|
|
1993
|
+
},
|
|
1985
1994
|
"warning"
|
|
1986
1995
|
);
|
|
1987
1996
|
response = {
|
|
@@ -2099,13 +2108,6 @@ var SocketController = class _SocketController {
|
|
|
2099
2108
|
"warning"
|
|
2100
2109
|
);
|
|
2101
2110
|
}
|
|
2102
|
-
if (result.errored) {
|
|
2103
|
-
errorCount++;
|
|
2104
|
-
if (errorCount > ERROR_LIMIT) {
|
|
2105
|
-
console.error("Too many errors, closing socket", URL);
|
|
2106
|
-
emit(`meta.socket_shutdown_requested:${fetchId}`, {});
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
2111
|
}
|
|
2110
2112
|
);
|
|
2111
2113
|
},
|
|
@@ -2126,7 +2128,7 @@ var SocketController = class _SocketController {
|
|
|
2126
2128
|
emitWhenReady?.(
|
|
2127
2129
|
"delegation",
|
|
2128
2130
|
ctx2,
|
|
2129
|
-
|
|
2131
|
+
ctx2.__timeout ?? 6e4,
|
|
2130
2132
|
(resultContext) => {
|
|
2131
2133
|
const requestDuration = Date.now() - requestSentAt;
|
|
2132
2134
|
const metadata = resultContext.__metadata;
|
|
@@ -2146,13 +2148,6 @@ var SocketController = class _SocketController {
|
|
|
2146
2148
|
}
|
|
2147
2149
|
);
|
|
2148
2150
|
pendingDelegationIds.delete(ctx2.__metadata.__deputyExecId);
|
|
2149
|
-
if (resultContext.errored) {
|
|
2150
|
-
errorCount++;
|
|
2151
|
-
if (errorCount > ERROR_LIMIT) {
|
|
2152
|
-
console.error("Too many errors, closing socket", URL);
|
|
2153
|
-
emit(`meta.socket_shutdown_requested:${fetchId}`, {});
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
2151
|
resolve(resultContext);
|
|
2157
2152
|
}
|
|
2158
2153
|
);
|
|
@@ -2179,13 +2174,6 @@ var SocketController = class _SocketController {
|
|
|
2179
2174
|
response
|
|
2180
2175
|
);
|
|
2181
2176
|
}
|
|
2182
|
-
if (response.errored) {
|
|
2183
|
-
errorCount++;
|
|
2184
|
-
if (errorCount > ERROR_LIMIT) {
|
|
2185
|
-
console.error("Too many errors, closing socket", URL);
|
|
2186
|
-
emit(`meta.socket_shutdown_requested:${fetchId}`, {});
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
2177
|
resolve(response);
|
|
2190
2178
|
});
|
|
2191
2179
|
});
|
|
@@ -3828,14 +3816,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3828
3816
|
}
|
|
3829
3817
|
}
|
|
3830
3818
|
},
|
|
3831
|
-
{ concurrency:
|
|
3819
|
+
{ concurrency: 30 }
|
|
3832
3820
|
) : CadenzaService.get("dbInsertRoutine"))?.then(
|
|
3833
3821
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
3834
3822
|
if (!ctx.__syncing) {
|
|
3835
3823
|
return;
|
|
3836
3824
|
}
|
|
3837
3825
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3838
|
-
delayMs:
|
|
3826
|
+
delayMs: 3e3
|
|
3839
3827
|
});
|
|
3840
3828
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
3841
3829
|
return true;
|
|
@@ -3853,7 +3841,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3853
3841
|
const { routines } = ctx;
|
|
3854
3842
|
if (!routines) return;
|
|
3855
3843
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3856
|
-
delayMs:
|
|
3844
|
+
delayMs: 3e3
|
|
3857
3845
|
});
|
|
3858
3846
|
for (const routine of routines) {
|
|
3859
3847
|
for (const task of routine.tasks) {
|
|
@@ -3897,7 +3885,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3897
3885
|
}
|
|
3898
3886
|
}
|
|
3899
3887
|
},
|
|
3900
|
-
{ concurrency:
|
|
3888
|
+
{ concurrency: 30 }
|
|
3901
3889
|
) : CadenzaService.get("dbInsertTaskToRoutineMap"))?.then(
|
|
3902
3890
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
3903
3891
|
if (!ctx.__syncing) {
|
|
@@ -3916,7 +3904,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3916
3904
|
"Split signals for registration",
|
|
3917
3905
|
function* (ctx) {
|
|
3918
3906
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3919
|
-
delayMs:
|
|
3907
|
+
delayMs: 3e3
|
|
3920
3908
|
});
|
|
3921
3909
|
const { signals } = ctx;
|
|
3922
3910
|
if (!signals) return;
|
|
@@ -3948,14 +3936,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3948
3936
|
}
|
|
3949
3937
|
}
|
|
3950
3938
|
},
|
|
3951
|
-
{ concurrency:
|
|
3939
|
+
{ concurrency: 30 }
|
|
3952
3940
|
) : CadenzaService.get("dbInsertSignalRegistry"))?.then(
|
|
3953
3941
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
3954
3942
|
if (!ctx.__syncing) {
|
|
3955
3943
|
return;
|
|
3956
3944
|
}
|
|
3957
3945
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3958
|
-
delayMs:
|
|
3946
|
+
delayMs: 3e3
|
|
3959
3947
|
});
|
|
3960
3948
|
return { signalName: ctx.__signal };
|
|
3961
3949
|
}).then(
|
|
@@ -3971,7 +3959,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3971
3959
|
"Split tasks for registration",
|
|
3972
3960
|
function* (ctx) {
|
|
3973
3961
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3974
|
-
delayMs:
|
|
3962
|
+
delayMs: 3e3
|
|
3975
3963
|
});
|
|
3976
3964
|
const tasks = ctx.tasks;
|
|
3977
3965
|
for (const task of tasks) {
|
|
@@ -4026,14 +4014,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4026
4014
|
}
|
|
4027
4015
|
}
|
|
4028
4016
|
},
|
|
4029
|
-
{ concurrency:
|
|
4017
|
+
{ concurrency: 30 }
|
|
4030
4018
|
) : CadenzaService.get("dbInsertTask"))?.then(
|
|
4031
4019
|
CadenzaService.createMetaTask("Record registration", (ctx) => {
|
|
4032
4020
|
if (!ctx.__syncing) {
|
|
4033
4021
|
return;
|
|
4034
4022
|
}
|
|
4035
4023
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4036
|
-
delayMs:
|
|
4024
|
+
delayMs: 3e3
|
|
4037
4025
|
});
|
|
4038
4026
|
CadenzaService.get(ctx.__taskName).registered = true;
|
|
4039
4027
|
return true;
|
|
@@ -4052,7 +4040,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4052
4040
|
return;
|
|
4053
4041
|
}
|
|
4054
4042
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4055
|
-
delayMs:
|
|
4043
|
+
delayMs: 3e3
|
|
4056
4044
|
});
|
|
4057
4045
|
CadenzaService.get(ctx.__taskName)?.registeredSignals.add(ctx.__signal);
|
|
4058
4046
|
}
|
|
@@ -4095,7 +4083,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4095
4083
|
}
|
|
4096
4084
|
}
|
|
4097
4085
|
},
|
|
4098
|
-
{ concurrency:
|
|
4086
|
+
{ concurrency: 30 }
|
|
4099
4087
|
) : CadenzaService.get("dbInsertSignalToTaskMap"))?.then(registerSignalTask)
|
|
4100
4088
|
);
|
|
4101
4089
|
this.registerTaskMapTask = CadenzaService.createMetaTask(
|
|
@@ -4103,7 +4091,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4103
4091
|
function* (ctx) {
|
|
4104
4092
|
const task = ctx.task;
|
|
4105
4093
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4106
|
-
delayMs:
|
|
4094
|
+
delayMs: 3e3
|
|
4107
4095
|
});
|
|
4108
4096
|
if (task.hidden || !task.register) return;
|
|
4109
4097
|
for (const t of task.nextTasks) {
|
|
@@ -4142,14 +4130,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4142
4130
|
}
|
|
4143
4131
|
}
|
|
4144
4132
|
},
|
|
4145
|
-
{ concurrency:
|
|
4133
|
+
{ concurrency: 30 }
|
|
4146
4134
|
) : CadenzaService.get("dbInsertDirectionalTaskGraphMap"))?.then(
|
|
4147
4135
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
4148
4136
|
if (!ctx.__syncing) {
|
|
4149
4137
|
return;
|
|
4150
4138
|
}
|
|
4151
4139
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4152
|
-
delayMs:
|
|
4140
|
+
delayMs: 3e3
|
|
4153
4141
|
});
|
|
4154
4142
|
CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
|
|
4155
4143
|
ctx.__nextTaskName
|
|
@@ -4195,7 +4183,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4195
4183
|
}
|
|
4196
4184
|
}
|
|
4197
4185
|
},
|
|
4198
|
-
{ concurrency:
|
|
4186
|
+
{ concurrency: 30 }
|
|
4199
4187
|
) : CadenzaService.get("dbInsertDirectionalTaskGraphMap"))?.then(
|
|
4200
4188
|
CadenzaService.createMetaTask(
|
|
4201
4189
|
"Record deputy relationship registration",
|
|
@@ -4204,14 +4192,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4204
4192
|
return;
|
|
4205
4193
|
}
|
|
4206
4194
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4207
|
-
delayMs:
|
|
4195
|
+
delayMs: 3e3
|
|
4208
4196
|
});
|
|
4209
4197
|
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
4210
4198
|
}
|
|
4211
4199
|
)
|
|
4212
4200
|
)
|
|
4213
4201
|
);
|
|
4214
|
-
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
4202
|
+
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
4203
|
+
"meta.sync_controller.sync_tick",
|
|
4204
|
+
"meta.service_registry.initial_sync_complete"
|
|
4205
|
+
).then(this.splitSignalsTask);
|
|
4215
4206
|
CadenzaService.registry.getAllTasks.clone().doOn("meta.sync_controller.synced_signals").then(this.splitTasksForRegistration);
|
|
4216
4207
|
CadenzaService.registry.getAllRoutines.clone().doOn("meta.sync_controller.synced_tasks").then(this.splitRoutinesTask);
|
|
4217
4208
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_tasks").then(
|
|
@@ -4247,7 +4238,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4247
4238
|
{ __syncing: true },
|
|
4248
4239
|
18e4
|
|
4249
4240
|
);
|
|
4250
|
-
CadenzaService.schedule("meta.sync_requested", { __syncing: true },
|
|
4241
|
+
CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
|
|
4251
4242
|
}
|
|
4252
4243
|
console.log("Syncing initiated", this.isCadenzaDBReady);
|
|
4253
4244
|
}
|