@onlineapps/conn-orch-registry 1.1.25 → 1.1.27

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": "@onlineapps/conn-orch-registry",
3
- "version": "1.1.25",
3
+ "version": "1.1.27",
4
4
  "license": "MIT",
5
5
  "description": "Connector-registry-client provides the core communication mechanism for microservices in this environment. It enables them to interact with a services_registry to receive and fulfill tasks by submitting heartbeats or their API descriptions.",
6
6
  "keywords": [
@@ -38,13 +38,12 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@onlineapps/conn-base-storage": "^1.0.0",
42
- "@onlineapps/mq-client-core": "^1.0.26",
41
+ "@onlineapps/conn-base-storage": "1.0.2",
42
+ "@onlineapps/mq-client-core": "1.0.62",
43
+ "@onlineapps/runtime-config": "1.0.2",
43
44
  "amqplib": "^0.10.9",
44
45
  "axios": "^1.12.2",
45
- "dotenv": "^16.6.1",
46
46
  "ioredis": "^5.8.0",
47
- "joi": "^17.9.2",
48
47
  "uuid": "^9.0.1"
49
48
  },
50
49
  "devDependencies": {
package/src/config.js CHANGED
@@ -1,52 +1,26 @@
1
+ 'use strict';
2
+
1
3
  /**
2
- * config.js
3
- *
4
- * Loads and validates configuration variables via environment variables.
5
- * Uses dotenv to load the .env file and Joi for validation.
4
+ * Runtime configuration schema for @onlineapps/conn-orch-registry.
6
5
  *
7
- * @module @onlineapps/connector-registry-client/src/config
6
+ * Uses @onlineapps/runtime-config for unified priority:
7
+ * 1. Explicit config
8
+ * 2. Environment variable
9
+ * 3. Module-owned defaults (from ./defaults.js)
8
10
  */
9
11
 
10
- // Load .env (if it exists)
11
- require('dotenv').config();
12
-
13
- const Joi = require('joi');
14
-
15
- // Define schema for environment variables
16
- const envSchema = Joi.object({
17
- AMQP_URL: Joi.string().uri().required()
18
- .description('AMQP URI for connecting to RabbitMQ'),
19
-
20
- SERVICE_NAME: Joi.string().required()
21
- .description('Name of the service to register'),
22
-
23
- SERVICE_VERSION: Joi.string().required()
24
- .description('Service version in SemVer format'),
25
-
26
- HEARTBEAT_INTERVAL: Joi.number().integer().min(1000).default(10000)
27
- .description('Interval for sending heartbeat messages in ms'),
28
-
29
- API_QUEUE: Joi.string().default('api_services_queuer')
30
- .description('Name of the queue for heartbeat and API requests'),
31
-
32
- REGISTRY_QUEUE: Joi.string().default('registry.register')
33
- .description('Name of the queue for registry messages')
34
- })
35
- .unknown() // allow additional variables
36
- .required();
37
-
38
- // Validate variables
39
- const { error, value: envVars } = envSchema.validate(process.env);
40
- if (error) {
41
- throw new Error(`Config validation error: ${error.message}`);
42
- }
43
-
44
- // Export configuration
45
- module.exports = {
46
- amqpUrl: envVars.AMQP_URL,
47
- serviceName: envVars.SERVICE_NAME,
48
- version: envVars.SERVICE_VERSION,
49
- heartbeatInterval: envVars.HEARTBEAT_INTERVAL,
50
- apiQueue: envVars.API_QUEUE,
51
- registryQueue: envVars.REGISTRY_QUEUE
52
- };
12
+ const { createRuntimeConfig } = require('@onlineapps/runtime-config');
13
+ const DEFAULTS = require('./defaults');
14
+
15
+ const runtimeCfg = createRuntimeConfig({
16
+ defaults: DEFAULTS,
17
+ schema: {
18
+ // Local spec fetch settings (optional; only required when auto-fetching spec)
19
+ servicePort: { env: 'PORT', type: 'number' },
20
+ specHost: { env: 'REGISTRY_SPEC_HOST', defaultKey: 'specHost' },
21
+ specProtocol: { env: 'REGISTRY_SPEC_PROTOCOL', defaultKey: 'specProtocol' },
22
+ specificationEndpoint: { env: 'REGISTRY_SPEC_ENDPOINT', defaultKey: 'specificationEndpoint' },
23
+ }
24
+ });
25
+
26
+ module.exports = runtimeCfg;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Module-owned defaults for @onlineapps/conn-orch-registry.
5
+ *
6
+ * Ownership rule:
7
+ * - Defaults here belong to the registry connector behavior (not infra topology).
8
+ * - Any required topology (e.g., service port for local spec fetch) must be provided via config/ENV.
9
+ */
10
+
11
+ module.exports = {
12
+ specificationEndpoint: '/api/v1/specification',
13
+
14
+ specProtocol: 'http',
15
+ specHost: '127.0.0.1',
16
+ };
17
+
18
+
@@ -20,6 +20,7 @@ const QueueManager = require('./queueManager');
20
20
  const RegistryEventConsumer = require('./registryEventConsumer');
21
21
  const { v4: uuidv4 } = require('uuid');
22
22
  const queueConfig = require('@onlineapps/mq-client-core/src/config/queueConfig');
23
+ const runtimeCfg = require('./config');
23
24
 
24
25
 
25
26
  class ServiceRegistryClient extends EventEmitter {
@@ -43,6 +44,7 @@ class ServiceRegistryClient extends EventEmitter {
43
44
  }
44
45
  this.serviceName = serviceName;
45
46
  this.version = version;
47
+ // Spec endpoint is still configurable, but defaults are module-owned and can be overridden via runtime config.
46
48
  this.specificationEndpoint = specificationEndpoint;
47
49
  this.heartbeatInterval = heartbeatInterval;
48
50
  this.apiQueue = apiQueue;
@@ -584,7 +586,12 @@ class ServiceRegistryClient extends EventEmitter {
584
586
  // If no spec provided, try to fetch it
585
587
  if (!spec) {
586
588
  try {
587
- const response = await fetch(`http://localhost:${process.env.PORT || 3000}${this.specificationEndpoint}`);
589
+ const resolved = runtimeCfg.resolve({ specificationEndpoint: this.specificationEndpoint });
590
+ if (!resolved.servicePort) {
591
+ throw new Error('[RegistryClient] Missing required config - Expected PORT (servicePort) to auto-fetch specification, or pass spec explicitly');
592
+ }
593
+ const url = `${resolved.specProtocol}://${resolved.specHost}:${resolved.servicePort}${resolved.specificationEndpoint}`;
594
+ const response = await fetch(url);
588
595
  if (response.ok) {
589
596
  spec = await response.json();
590
597
  }