@thzero/library_server_service_grpc 0.13.18 → 0.14.2

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.
Files changed (2) hide show
  1. package/client.js +18 -12
  2. package/package.json +8 -8
package/client.js CHANGED
@@ -40,7 +40,7 @@ class BaseClientGrpcService extends Service {
40
40
  });
41
41
  }
42
42
 
43
- _credentials(correlationId, host) {
43
+ _credentials(correlationId) {
44
44
  return grpc.credentials.createInsecure();
45
45
  }
46
46
 
@@ -52,14 +52,16 @@ class BaseClientGrpcService extends Service {
52
52
  secure: false
53
53
  };
54
54
 
55
- if (opts.resource)
56
- host = this._hostFromResource(correlationId, host, opts.resource, opts);
57
- else if (!String.url(opts.url)) {
58
- host.url = opts.url;
59
- host.secure = opts.secure;
55
+ if (opts) {
56
+ if (opts.resource)
57
+ host = await this._hostFromResource(correlationId, host, opts.resource, opts);
58
+ else if (!String.url(opts.url)) {
59
+ host.url = opts.url;
60
+ host.secure = opts.secure;
61
+ }
60
62
  }
61
63
  else
62
- host = this._hostFromConfig(correlationId, key, opts);
64
+ host = await this._hostFromConfig(correlationId, host, key, opts);
63
65
 
64
66
  return host;
65
67
  }
@@ -70,19 +72,23 @@ class BaseClientGrpcService extends Service {
70
72
 
71
73
  const config = this._config.getBackend(key);
72
74
  this._enforceNotNull('BaseClientGrpcService', '_hostFromConfig', config, 'config', correlationId);
73
- this._enforceNotEmpty('BaseClientGrpcService', '_hostFromConfig', config.host, 'config.host', correlationId);
75
+ this._enforceNotEmpty('BaseClientGrpcService', '_hostFromConfig', config.url, 'config.url', correlationId);
74
76
 
75
77
  host.url = config.url;
76
-
78
+
77
79
  this._logger.debug('BaseServerGrpcService', '_host', 'config.discoverable', config.discoverable, correlationId);
80
+ if (!config.discoverable)
81
+ return resource;
82
+
83
+ this._logger.debug('BaseServerGrpcService', '_host', '_serviceDiscoveryResources', (this._serviceDiscoveryResources != null), correlationId);
78
84
  if (!(this._serviceDiscoveryResources && config.discoverable))
79
- return this.host;
85
+ return host;
80
86
 
81
87
  this._logger.debug('BaseServerGrpcService', '_host', 'config.discoverable.enabled', config.discoverable.enabled, correlationId);
82
88
  const enabled = config.discoverable.enabled === false ? false : true;
83
89
  this._logger.debug('BaseServerGrpcService', '_host', 'enabled', enabled, correlationId);
84
90
  if (!enabled)
85
- return this.host;
91
+ return host;
86
92
 
87
93
  host = this._hosts.get(key);
88
94
  if (host)
@@ -97,7 +103,7 @@ class BaseClientGrpcService extends Service {
97
103
  this._enforceNotNull('BaseClientGrpcService', '_host', config.discoverable.name, 'discoveryName', correlationId);
98
104
 
99
105
  const response = await this._serviceDiscoveryResources.getService(correlationId, config.discoverable.name);
100
- if (!response.success)
106
+ if (this._hasFailed(response))
101
107
  return null;
102
108
 
103
109
  host = await this._hostFromResource(correlationId, host, response.results);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@thzero/library_server_service_grpc",
3
- "version": "0.13.18",
3
+ "version": "0.14.2",
4
4
  "version_major": 0,
5
- "version_minor": 13,
6
- "version_patch": 18,
7
- "version_date": "09/26/2021",
5
+ "version_minor": 14,
6
+ "version_patch": 2,
7
+ "version_date": "10/12/2021",
8
8
  "description": "",
9
9
  "author": "thZero",
10
10
  "repository": {
@@ -27,11 +27,11 @@
27
27
  "@grpc/grpc-js": "^1.3.7"
28
28
  },
29
29
  "devDependencies": {
30
- "@thzero/library_cli": "^0.13.19"
30
+ "@thzero/library_cli": "^0.13.20"
31
31
  },
32
32
  "peerDependencies": {
33
- "@thzero/library_common": "^0.13",
34
- "@thzero/library_common_service": "^0.13",
35
- "@thzero/library_server": "^0.13"
33
+ "@thzero/library_common": "^0.14",
34
+ "@thzero/library_common_service": "^0.14",
35
+ "@thzero/library_server": "^0.14"
36
36
  }
37
37
  }