arcway 0.4.2 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arcway",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "A convention-based framework for building modular monoliths with strict domain boundaries.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -111,6 +111,7 @@ async function boot(options) {
111
111
  callbacks,
112
112
  workerPool,
113
113
  plugins,
114
+ appConfig: config,
114
115
  });
115
116
  await jobRunner.init();
116
117
 
@@ -38,6 +38,7 @@ async function discoverJobs(jobsDir) {
38
38
  class JobRunner {
39
39
  _dispatcher;
40
40
  _config;
41
+ _appConfig;
41
42
  _log;
42
43
  _appContext;
43
44
  _jobs = [];
@@ -64,9 +65,11 @@ class JobRunner {
64
65
  callbacks,
65
66
  workerPool,
66
67
  plugins,
68
+ appConfig,
67
69
  } = {},
68
70
  ) {
69
71
  this._config = config;
72
+ this._appConfig = appConfig ?? config;
70
73
  this._log = log;
71
74
  this._dispatcher = new JobDispatcher({
72
75
  backoffMs: config?.backoffMs,
@@ -102,11 +105,10 @@ class JobRunner {
102
105
 
103
106
  async init() {
104
107
  const jobsDir = this._config?.dir;
105
- if (!jobsDir) return;
106
108
 
107
109
  // Discover and register user jobs. `filePath` is captured so the
108
110
  // dispatcher can dynamic-import the handler inside a worker thread.
109
- const discovered = await discoverJobs(jobsDir);
111
+ const discovered = jobsDir ? await discoverJobs(jobsDir) : [];
110
112
  const pluginJobs = (await this._appContext.plugins?.discoverJobs?.()) ?? [];
111
113
  for (const { definition, fileName, filePath } of [...discovered, ...pluginJobs]) {
112
114
  this._dispatcher.register('app', definition, this._appContext, filePath);
@@ -133,7 +135,7 @@ class JobRunner {
133
135
  meta: this._appContext.meta,
134
136
  log: this._log.extend({ logger: SYSTEM_JOB_DOMAIN }),
135
137
  };
136
- const systemJobs = registerSystemJobs(this._config, this._dispatcher, systemContext);
138
+ const systemJobs = registerSystemJobs(this._appConfig, this._dispatcher, systemContext);
137
139
  for (const sj of systemJobs) {
138
140
  this._log?.info(` ${sj.jobName} (system${sj.schedule ? `, ${sj.schedule}` : ''})`);
139
141
  }