@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.mjs
CHANGED
|
@@ -130,6 +130,7 @@ var DeputyTask = class extends Task {
|
|
|
130
130
|
const ctx = context.getContext();
|
|
131
131
|
const metadata = context.getMetadata();
|
|
132
132
|
const deputyContext = {
|
|
133
|
+
__timeout: this.timeout,
|
|
133
134
|
__localTaskName: this.name,
|
|
134
135
|
__localTaskVersion: this.version,
|
|
135
136
|
__localServiceName: CadenzaService.serviceRegistry.serviceName,
|
|
@@ -512,8 +513,11 @@ var ServiceRegistry = class _ServiceRegistry {
|
|
|
512
513
|
);
|
|
513
514
|
return joinedContext;
|
|
514
515
|
}
|
|
515
|
-
).then(this.handleGlobalSignalRegistrationTask);
|
|
516
|
+
).emits("meta.service_registry.initial_sync_complete").then(this.handleGlobalSignalRegistrationTask);
|
|
516
517
|
this.fullSyncTask = CadenzaService.createMetaRoutine("Full sync", [
|
|
518
|
+
CadenzaService.createTask("Confirm full sync", () => {
|
|
519
|
+
console.log("Confirming full sync...");
|
|
520
|
+
}),
|
|
517
521
|
CadenzaService.createCadenzaDBQueryTask("signal_to_task_map", {
|
|
518
522
|
filter: {
|
|
519
523
|
isGlobal: true
|
|
@@ -1899,7 +1903,7 @@ var SocketController = class _SocketController {
|
|
|
1899
1903
|
transports: ["websocket"],
|
|
1900
1904
|
autoConnect: false
|
|
1901
1905
|
});
|
|
1902
|
-
emitWhenReady = (event, data, timeoutMs =
|
|
1906
|
+
emitWhenReady = (event, data, timeoutMs = 6e4, ack) => {
|
|
1903
1907
|
return new Promise((resolve) => {
|
|
1904
1908
|
const tryEmit = () => {
|
|
1905
1909
|
if (!socket?.connected) {
|
|
@@ -1933,7 +1937,12 @@ var SocketController = class _SocketController {
|
|
|
1933
1937
|
if (err) {
|
|
1934
1938
|
CadenzaService.log(
|
|
1935
1939
|
"Socket timeout.",
|
|
1936
|
-
{
|
|
1940
|
+
{
|
|
1941
|
+
event,
|
|
1942
|
+
error: err.message,
|
|
1943
|
+
socketId: socket?.id,
|
|
1944
|
+
serviceName
|
|
1945
|
+
},
|
|
1937
1946
|
"warning"
|
|
1938
1947
|
);
|
|
1939
1948
|
response = {
|
|
@@ -2051,13 +2060,6 @@ var SocketController = class _SocketController {
|
|
|
2051
2060
|
"warning"
|
|
2052
2061
|
);
|
|
2053
2062
|
}
|
|
2054
|
-
if (result.errored) {
|
|
2055
|
-
errorCount++;
|
|
2056
|
-
if (errorCount > ERROR_LIMIT) {
|
|
2057
|
-
console.error("Too many errors, closing socket", URL);
|
|
2058
|
-
emit(`meta.socket_shutdown_requested:${fetchId}`, {});
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
2063
|
}
|
|
2062
2064
|
);
|
|
2063
2065
|
},
|
|
@@ -2078,7 +2080,7 @@ var SocketController = class _SocketController {
|
|
|
2078
2080
|
emitWhenReady?.(
|
|
2079
2081
|
"delegation",
|
|
2080
2082
|
ctx2,
|
|
2081
|
-
|
|
2083
|
+
ctx2.__timeout ?? 6e4,
|
|
2082
2084
|
(resultContext) => {
|
|
2083
2085
|
const requestDuration = Date.now() - requestSentAt;
|
|
2084
2086
|
const metadata = resultContext.__metadata;
|
|
@@ -2098,13 +2100,6 @@ var SocketController = class _SocketController {
|
|
|
2098
2100
|
}
|
|
2099
2101
|
);
|
|
2100
2102
|
pendingDelegationIds.delete(ctx2.__metadata.__deputyExecId);
|
|
2101
|
-
if (resultContext.errored) {
|
|
2102
|
-
errorCount++;
|
|
2103
|
-
if (errorCount > ERROR_LIMIT) {
|
|
2104
|
-
console.error("Too many errors, closing socket", URL);
|
|
2105
|
-
emit(`meta.socket_shutdown_requested:${fetchId}`, {});
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
2103
|
resolve(resultContext);
|
|
2109
2104
|
}
|
|
2110
2105
|
);
|
|
@@ -2131,13 +2126,6 @@ var SocketController = class _SocketController {
|
|
|
2131
2126
|
response
|
|
2132
2127
|
);
|
|
2133
2128
|
}
|
|
2134
|
-
if (response.errored) {
|
|
2135
|
-
errorCount++;
|
|
2136
|
-
if (errorCount > ERROR_LIMIT) {
|
|
2137
|
-
console.error("Too many errors, closing socket", URL);
|
|
2138
|
-
emit(`meta.socket_shutdown_requested:${fetchId}`, {});
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
2129
|
resolve(response);
|
|
2142
2130
|
});
|
|
2143
2131
|
});
|
|
@@ -3780,14 +3768,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3780
3768
|
}
|
|
3781
3769
|
}
|
|
3782
3770
|
},
|
|
3783
|
-
{ concurrency:
|
|
3771
|
+
{ concurrency: 30 }
|
|
3784
3772
|
) : CadenzaService.get("dbInsertRoutine"))?.then(
|
|
3785
3773
|
CadenzaService.createMetaTask("Register routine", (ctx) => {
|
|
3786
3774
|
if (!ctx.__syncing) {
|
|
3787
3775
|
return;
|
|
3788
3776
|
}
|
|
3789
3777
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3790
|
-
delayMs:
|
|
3778
|
+
delayMs: 3e3
|
|
3791
3779
|
});
|
|
3792
3780
|
CadenzaService.getRoutine(ctx.__routineName).registered = true;
|
|
3793
3781
|
return true;
|
|
@@ -3805,7 +3793,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3805
3793
|
const { routines } = ctx;
|
|
3806
3794
|
if (!routines) return;
|
|
3807
3795
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3808
|
-
delayMs:
|
|
3796
|
+
delayMs: 3e3
|
|
3809
3797
|
});
|
|
3810
3798
|
for (const routine of routines) {
|
|
3811
3799
|
for (const task of routine.tasks) {
|
|
@@ -3849,7 +3837,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3849
3837
|
}
|
|
3850
3838
|
}
|
|
3851
3839
|
},
|
|
3852
|
-
{ concurrency:
|
|
3840
|
+
{ concurrency: 30 }
|
|
3853
3841
|
) : CadenzaService.get("dbInsertTaskToRoutineMap"))?.then(
|
|
3854
3842
|
CadenzaService.createMetaTask("Register routine task", (ctx) => {
|
|
3855
3843
|
if (!ctx.__syncing) {
|
|
@@ -3868,7 +3856,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3868
3856
|
"Split signals for registration",
|
|
3869
3857
|
function* (ctx) {
|
|
3870
3858
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3871
|
-
delayMs:
|
|
3859
|
+
delayMs: 3e3
|
|
3872
3860
|
});
|
|
3873
3861
|
const { signals } = ctx;
|
|
3874
3862
|
if (!signals) return;
|
|
@@ -3900,14 +3888,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3900
3888
|
}
|
|
3901
3889
|
}
|
|
3902
3890
|
},
|
|
3903
|
-
{ concurrency:
|
|
3891
|
+
{ concurrency: 30 }
|
|
3904
3892
|
) : CadenzaService.get("dbInsertSignalRegistry"))?.then(
|
|
3905
3893
|
CadenzaService.createMetaTask("Process signal registration", (ctx) => {
|
|
3906
3894
|
if (!ctx.__syncing) {
|
|
3907
3895
|
return;
|
|
3908
3896
|
}
|
|
3909
3897
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3910
|
-
delayMs:
|
|
3898
|
+
delayMs: 3e3
|
|
3911
3899
|
});
|
|
3912
3900
|
return { signalName: ctx.__signal };
|
|
3913
3901
|
}).then(
|
|
@@ -3923,7 +3911,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3923
3911
|
"Split tasks for registration",
|
|
3924
3912
|
function* (ctx) {
|
|
3925
3913
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3926
|
-
delayMs:
|
|
3914
|
+
delayMs: 3e3
|
|
3927
3915
|
});
|
|
3928
3916
|
const tasks = ctx.tasks;
|
|
3929
3917
|
for (const task of tasks) {
|
|
@@ -3978,14 +3966,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
3978
3966
|
}
|
|
3979
3967
|
}
|
|
3980
3968
|
},
|
|
3981
|
-
{ concurrency:
|
|
3969
|
+
{ concurrency: 30 }
|
|
3982
3970
|
) : CadenzaService.get("dbInsertTask"))?.then(
|
|
3983
3971
|
CadenzaService.createMetaTask("Record registration", (ctx) => {
|
|
3984
3972
|
if (!ctx.__syncing) {
|
|
3985
3973
|
return;
|
|
3986
3974
|
}
|
|
3987
3975
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
3988
|
-
delayMs:
|
|
3976
|
+
delayMs: 3e3
|
|
3989
3977
|
});
|
|
3990
3978
|
CadenzaService.get(ctx.__taskName).registered = true;
|
|
3991
3979
|
return true;
|
|
@@ -4004,7 +3992,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4004
3992
|
return;
|
|
4005
3993
|
}
|
|
4006
3994
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4007
|
-
delayMs:
|
|
3995
|
+
delayMs: 3e3
|
|
4008
3996
|
});
|
|
4009
3997
|
CadenzaService.get(ctx.__taskName)?.registeredSignals.add(ctx.__signal);
|
|
4010
3998
|
}
|
|
@@ -4047,7 +4035,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4047
4035
|
}
|
|
4048
4036
|
}
|
|
4049
4037
|
},
|
|
4050
|
-
{ concurrency:
|
|
4038
|
+
{ concurrency: 30 }
|
|
4051
4039
|
) : CadenzaService.get("dbInsertSignalToTaskMap"))?.then(registerSignalTask)
|
|
4052
4040
|
);
|
|
4053
4041
|
this.registerTaskMapTask = CadenzaService.createMetaTask(
|
|
@@ -4055,7 +4043,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4055
4043
|
function* (ctx) {
|
|
4056
4044
|
const task = ctx.task;
|
|
4057
4045
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4058
|
-
delayMs:
|
|
4046
|
+
delayMs: 3e3
|
|
4059
4047
|
});
|
|
4060
4048
|
if (task.hidden || !task.register) return;
|
|
4061
4049
|
for (const t of task.nextTasks) {
|
|
@@ -4094,14 +4082,14 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4094
4082
|
}
|
|
4095
4083
|
}
|
|
4096
4084
|
},
|
|
4097
|
-
{ concurrency:
|
|
4085
|
+
{ concurrency: 30 }
|
|
4098
4086
|
) : CadenzaService.get("dbInsertDirectionalTaskGraphMap"))?.then(
|
|
4099
4087
|
CadenzaService.createMetaTask("Record task map registration", (ctx) => {
|
|
4100
4088
|
if (!ctx.__syncing) {
|
|
4101
4089
|
return;
|
|
4102
4090
|
}
|
|
4103
4091
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4104
|
-
delayMs:
|
|
4092
|
+
delayMs: 3e3
|
|
4105
4093
|
});
|
|
4106
4094
|
CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
|
|
4107
4095
|
ctx.__nextTaskName
|
|
@@ -4147,7 +4135,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4147
4135
|
}
|
|
4148
4136
|
}
|
|
4149
4137
|
},
|
|
4150
|
-
{ concurrency:
|
|
4138
|
+
{ concurrency: 30 }
|
|
4151
4139
|
) : CadenzaService.get("dbInsertDirectionalTaskGraphMap"))?.then(
|
|
4152
4140
|
CadenzaService.createMetaTask(
|
|
4153
4141
|
"Record deputy relationship registration",
|
|
@@ -4156,14 +4144,17 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4156
4144
|
return;
|
|
4157
4145
|
}
|
|
4158
4146
|
CadenzaService.debounce("meta.sync_controller.synced_resource", {
|
|
4159
|
-
delayMs:
|
|
4147
|
+
delayMs: 3e3
|
|
4160
4148
|
});
|
|
4161
4149
|
CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
|
|
4162
4150
|
}
|
|
4163
4151
|
)
|
|
4164
4152
|
)
|
|
4165
4153
|
);
|
|
4166
|
-
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
4154
|
+
CadenzaService.signalBroker.getSignalsTask.clone().doOn(
|
|
4155
|
+
"meta.sync_controller.sync_tick",
|
|
4156
|
+
"meta.service_registry.initial_sync_complete"
|
|
4157
|
+
).then(this.splitSignalsTask);
|
|
4167
4158
|
CadenzaService.registry.getAllTasks.clone().doOn("meta.sync_controller.synced_signals").then(this.splitTasksForRegistration);
|
|
4168
4159
|
CadenzaService.registry.getAllRoutines.clone().doOn("meta.sync_controller.synced_tasks").then(this.splitRoutinesTask);
|
|
4169
4160
|
CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_tasks").then(
|
|
@@ -4199,7 +4190,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
4199
4190
|
{ __syncing: true },
|
|
4200
4191
|
18e4
|
|
4201
4192
|
);
|
|
4202
|
-
CadenzaService.schedule("meta.sync_requested", { __syncing: true },
|
|
4193
|
+
CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
|
|
4203
4194
|
}
|
|
4204
4195
|
console.log("Syncing initiated", this.isCadenzaDBReady);
|
|
4205
4196
|
}
|