@onlineapps/conn-orch-registry 1.1.45 → 1.1.46
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/src/registryClient.js +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-orch-registry",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.46",
|
|
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": [
|
package/src/registryClient.js
CHANGED
|
@@ -695,6 +695,41 @@ class ServiceRegistryClient extends EventEmitter {
|
|
|
695
695
|
return this.eventConsumer.getServiceSpec(serviceName);
|
|
696
696
|
}
|
|
697
697
|
|
|
698
|
+
/**
|
|
699
|
+
* Get basic service state for service discovery.
|
|
700
|
+
*
|
|
701
|
+
* cookbook-router expects `registryClient.getService(serviceName)` to exist and
|
|
702
|
+
* return an object with `status`. RegistryEventConsumer stores status as
|
|
703
|
+
* 'ACTIVE'/'INACTIVE' (uppercase), so we normalize to lowercase.
|
|
704
|
+
*
|
|
705
|
+
* @param {string} serviceName
|
|
706
|
+
* @returns {Promise<{serviceName: string, status: 'active'|'inactive', version?: string, fingerprint?: string, bucket?: string, path?: string, updatedAt?: string} | null>}
|
|
707
|
+
*/
|
|
708
|
+
async getService(serviceName) {
|
|
709
|
+
if (!this.eventConsumer) {
|
|
710
|
+
throw new Error('[RegistryClient] getService - Event consumer not initialized. Fix: call subscribeToChanges() before service discovery.');
|
|
711
|
+
}
|
|
712
|
+
if (!serviceName || typeof serviceName !== 'string') {
|
|
713
|
+
throw new Error('[RegistryClient] getService - serviceName is required and must be a string');
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const info = this.eventConsumer.getServiceInfo(serviceName);
|
|
717
|
+
if (!info) {
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
const normalizedStatus = info.status === 'ACTIVE' ? 'active' : 'inactive';
|
|
722
|
+
return {
|
|
723
|
+
serviceName,
|
|
724
|
+
status: normalizedStatus,
|
|
725
|
+
version: info.version,
|
|
726
|
+
fingerprint: info.fingerprint,
|
|
727
|
+
bucket: info.bucket,
|
|
728
|
+
path: info.path,
|
|
729
|
+
updatedAt: info.updatedAt
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
698
733
|
/**
|
|
699
734
|
* Check if service is active (requires subscribeToChanges)
|
|
700
735
|
* @param {string} serviceName - Name of the service
|