arcway 0.4.1 → 0.4.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 +1 -1
- package/server/jobs/runner.js +12 -4
- package/server/mail/index.js +2 -0
package/package.json
CHANGED
package/server/jobs/runner.js
CHANGED
|
@@ -102,11 +102,10 @@ class JobRunner {
|
|
|
102
102
|
|
|
103
103
|
async init() {
|
|
104
104
|
const jobsDir = this._config?.dir;
|
|
105
|
-
if (!jobsDir) return;
|
|
106
105
|
|
|
107
106
|
// Discover and register user jobs. `filePath` is captured so the
|
|
108
107
|
// dispatcher can dynamic-import the handler inside a worker thread.
|
|
109
|
-
const discovered = await discoverJobs(jobsDir);
|
|
108
|
+
const discovered = jobsDir ? await discoverJobs(jobsDir) : [];
|
|
110
109
|
const pluginJobs = (await this._appContext.plugins?.discoverJobs?.()) ?? [];
|
|
111
110
|
for (const { definition, fileName, filePath } of [...discovered, ...pluginJobs]) {
|
|
112
111
|
this._dispatcher.register('app', definition, this._appContext, filePath);
|
|
@@ -156,9 +155,18 @@ class JobRunner {
|
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
for (const sj of systemJobs) {
|
|
159
|
-
|
|
158
|
+
const qualifiedName = `${sj.domainName}/${sj.jobName}`;
|
|
159
|
+
if (sj.schedule === 'continuous') {
|
|
160
|
+
const registered = this._dispatcher.registered.get(qualifiedName);
|
|
161
|
+
this._continuousJobs.push({
|
|
162
|
+
qualifiedName,
|
|
163
|
+
handler: registered.definition.handler,
|
|
164
|
+
cooldownMs: registered.definition.cooldownMs,
|
|
165
|
+
appContext: registered.store,
|
|
166
|
+
});
|
|
167
|
+
} else if (sj.schedule) {
|
|
160
168
|
this._cronEntries.push({
|
|
161
|
-
qualifiedName
|
|
169
|
+
qualifiedName,
|
|
162
170
|
fields: parseCron(sj.schedule),
|
|
163
171
|
});
|
|
164
172
|
}
|
package/server/mail/index.js
CHANGED
|
@@ -90,6 +90,8 @@ function registerSendJob(driver, queue, throughput) {
|
|
|
90
90
|
addSystemJobEntry({
|
|
91
91
|
definition: {
|
|
92
92
|
name: MAIL_JOB_NAME,
|
|
93
|
+
schedule: 'continuous',
|
|
94
|
+
cooldownMs: 1000,
|
|
93
95
|
handler: async () => {
|
|
94
96
|
if (!queue) return;
|
|
95
97
|
const items = await queue.pop(MAIL_TOPIC, 10);
|