@hazeljs/discovery 0.7.9 → 0.8.1
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/README.md +29 -25
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -260,7 +260,7 @@ const consul = new Consul({
|
|
|
260
260
|
});
|
|
261
261
|
|
|
262
262
|
const backend = new ConsulRegistryBackend(consul, {
|
|
263
|
-
ttl: '30s',
|
|
263
|
+
ttl: '30s', // TTL check interval (supports "30s", "5m", "1h")
|
|
264
264
|
datacenter: 'dc1',
|
|
265
265
|
});
|
|
266
266
|
|
|
@@ -298,19 +298,19 @@ const client = new DiscoveryClient({}, backend);
|
|
|
298
298
|
|
|
299
299
|
`ServiceClient` only retries on transient errors. Client errors (4xx) are thrown immediately without wasting retries:
|
|
300
300
|
|
|
301
|
-
| Error Type
|
|
302
|
-
|
|
303
|
-
| Network errors (ECONNREFUSED, timeout) | Yes
|
|
304
|
-
| 502 Bad Gateway
|
|
305
|
-
| 503 Service Unavailable
|
|
306
|
-
| 504 Gateway Timeout
|
|
307
|
-
| 408 Request Timeout
|
|
308
|
-
| 429 Too Many Requests
|
|
309
|
-
| 400 Bad Request
|
|
310
|
-
| 401 Unauthorized
|
|
311
|
-
| 403 Forbidden
|
|
312
|
-
| 404 Not Found
|
|
313
|
-
| Other 4xx
|
|
301
|
+
| Error Type | Retried? |
|
|
302
|
+
| -------------------------------------- | -------- |
|
|
303
|
+
| Network errors (ECONNREFUSED, timeout) | Yes |
|
|
304
|
+
| 502 Bad Gateway | Yes |
|
|
305
|
+
| 503 Service Unavailable | Yes |
|
|
306
|
+
| 504 Gateway Timeout | Yes |
|
|
307
|
+
| 408 Request Timeout | Yes |
|
|
308
|
+
| 429 Too Many Requests | Yes |
|
|
309
|
+
| 400 Bad Request | No |
|
|
310
|
+
| 401 Unauthorized | No |
|
|
311
|
+
| 403 Forbidden | No |
|
|
312
|
+
| 404 Not Found | No |
|
|
313
|
+
| Other 4xx | No |
|
|
314
314
|
|
|
315
315
|
## Custom Logging
|
|
316
316
|
|
|
@@ -339,8 +339,8 @@ import { ServiceRegistry, ConfigValidationError } from '@hazeljs/discovery';
|
|
|
339
339
|
|
|
340
340
|
try {
|
|
341
341
|
const registry = new ServiceRegistry({
|
|
342
|
-
name: '',
|
|
343
|
-
port: -1,
|
|
342
|
+
name: '', // invalid: empty string
|
|
343
|
+
port: -1, // invalid: negative port
|
|
344
344
|
});
|
|
345
345
|
} catch (error) {
|
|
346
346
|
if (error instanceof ConfigValidationError) {
|
|
@@ -370,7 +370,11 @@ class ServiceRegistry {
|
|
|
370
370
|
class DiscoveryClient {
|
|
371
371
|
constructor(config?: DiscoveryClientConfig, backend?: RegistryBackend);
|
|
372
372
|
getInstances(serviceName: string, filter?: ServiceFilter): Promise<ServiceInstance[]>;
|
|
373
|
-
getInstance(
|
|
373
|
+
getInstance(
|
|
374
|
+
serviceName: string,
|
|
375
|
+
strategy?: string,
|
|
376
|
+
filter?: ServiceFilter
|
|
377
|
+
): Promise<ServiceInstance | null>;
|
|
374
378
|
getAllServices(): Promise<string[]>;
|
|
375
379
|
clearCache(serviceName?: string): void;
|
|
376
380
|
getLoadBalancerFactory(): LoadBalancerFactory;
|
|
@@ -399,8 +403,8 @@ interface ServiceRegistryConfig {
|
|
|
399
403
|
port: number;
|
|
400
404
|
host?: string;
|
|
401
405
|
protocol?: 'http' | 'https' | 'grpc';
|
|
402
|
-
healthCheckPath?: string;
|
|
403
|
-
healthCheckInterval?: number;
|
|
406
|
+
healthCheckPath?: string; // default: '/health'
|
|
407
|
+
healthCheckInterval?: number; // default: 30000 (ms)
|
|
404
408
|
metadata?: Record<string, unknown>;
|
|
405
409
|
zone?: string;
|
|
406
410
|
tags?: string[];
|
|
@@ -408,17 +412,17 @@ interface ServiceRegistryConfig {
|
|
|
408
412
|
|
|
409
413
|
interface DiscoveryClientConfig {
|
|
410
414
|
cacheEnabled?: boolean;
|
|
411
|
-
cacheTTL?: number;
|
|
412
|
-
refreshInterval?: number;
|
|
415
|
+
cacheTTL?: number; // default: 30000 (ms)
|
|
416
|
+
refreshInterval?: number; // auto-refresh cache interval (ms)
|
|
413
417
|
}
|
|
414
418
|
|
|
415
419
|
interface ServiceClientConfig {
|
|
416
420
|
serviceName: string;
|
|
417
|
-
loadBalancingStrategy?: string;
|
|
421
|
+
loadBalancingStrategy?: string; // default: 'round-robin'
|
|
418
422
|
filter?: ServiceFilter;
|
|
419
|
-
timeout?: number;
|
|
420
|
-
retries?: number;
|
|
421
|
-
retryDelay?: number;
|
|
423
|
+
timeout?: number; // default: 5000 (ms)
|
|
424
|
+
retries?: number; // default: 3
|
|
425
|
+
retryDelay?: number; // default: 1000 (ms)
|
|
422
426
|
}
|
|
423
427
|
```
|
|
424
428
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hazeljs/discovery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Service discovery and registry for HazelJS microservices - Eureka-inspired with multiple backend support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"clean": "rm -rf dist"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@hazeljs/core": "^0.
|
|
22
|
-
"@hazeljs/resilience": "^0.
|
|
21
|
+
"@hazeljs/core": "^0.8.1",
|
|
22
|
+
"@hazeljs/resilience": "^0.8.1",
|
|
23
23
|
"axios": "^1.14.0",
|
|
24
24
|
"reflect-metadata": "^0.2.2"
|
|
25
25
|
},
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"url": "https://github.com/hazeljs/hazel-js/issues"
|
|
78
78
|
},
|
|
79
79
|
"homepage": "https://hazeljs.ai",
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "8b7685d1250c4622f25d83992f58e13a59bb3dba"
|
|
81
81
|
}
|