@naman_deep_singh/communication-core 1.0.0

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 (134) hide show
  1. package/README.md +345 -0
  2. package/dist/cjs/abstract/BaseCircuitBreaker.js +253 -0
  3. package/dist/cjs/abstract/BaseClient.js +298 -0
  4. package/dist/cjs/abstract/BaseCompressionManager.js +377 -0
  5. package/dist/cjs/abstract/BaseConnectionPool.js +543 -0
  6. package/dist/cjs/abstract/BaseInterceptor.js +235 -0
  7. package/dist/cjs/abstract/BaseLoadBalancer.js +269 -0
  8. package/dist/cjs/abstract/BaseProtocol.js +269 -0
  9. package/dist/cjs/abstract/BaseRetryStrategy.js +255 -0
  10. package/dist/cjs/abstract/BaseSerializer.js +341 -0
  11. package/dist/cjs/abstract/BaseServiceDiscoverer.js +254 -0
  12. package/dist/cjs/abstract/BaseTimeoutManager.js +295 -0
  13. package/dist/cjs/abstract/index.js +25 -0
  14. package/dist/cjs/errors/CircuitBreakerError.js +16 -0
  15. package/dist/cjs/errors/CommunicationError.js +15 -0
  16. package/dist/cjs/errors/ConnectionError.js +15 -0
  17. package/dist/cjs/errors/DiscoveryError.js +15 -0
  18. package/dist/cjs/errors/LoadBalancerError.js +15 -0
  19. package/dist/cjs/errors/ProtocolError.js +15 -0
  20. package/dist/cjs/errors/RetryError.js +16 -0
  21. package/dist/cjs/errors/SerializationError.js +15 -0
  22. package/dist/cjs/errors/ServiceUnavailableError.js +15 -0
  23. package/dist/cjs/errors/TimeoutError.js +16 -0
  24. package/dist/cjs/errors/communicationErrorCodes.js +35 -0
  25. package/dist/cjs/errors/index.js +31 -0
  26. package/dist/cjs/index.js +38 -0
  27. package/dist/cjs/interfaces/CircuitBreaker.interface.js +6 -0
  28. package/dist/cjs/interfaces/Client.interface.js +6 -0
  29. package/dist/cjs/interfaces/Compression.interface.js +6 -0
  30. package/dist/cjs/interfaces/ConnectionPool.interface.js +6 -0
  31. package/dist/cjs/interfaces/Interceptor.interface.js +6 -0
  32. package/dist/cjs/interfaces/LoadBalancer.interface.js +2 -0
  33. package/dist/cjs/interfaces/Protocol.interface.js +6 -0
  34. package/dist/cjs/interfaces/RetryStrategy.interface.js +6 -0
  35. package/dist/cjs/interfaces/Serializer.interface.js +2 -0
  36. package/dist/cjs/interfaces/ServiceDiscovery.interface.js +6 -0
  37. package/dist/cjs/interfaces/Timeout.interface.js +6 -0
  38. package/dist/cjs/interfaces/index.js +6 -0
  39. package/dist/cjs/types/config.js +6 -0
  40. package/dist/cjs/types/events.js +6 -0
  41. package/dist/cjs/types/index.js +6 -0
  42. package/dist/cjs/types/request.js +6 -0
  43. package/dist/cjs/types/response.js +6 -0
  44. package/dist/cjs/types/service.js +6 -0
  45. package/dist/cjs/utils.js +200 -0
  46. package/dist/esm/abstract/BaseCircuitBreaker.js +249 -0
  47. package/dist/esm/abstract/BaseClient.js +294 -0
  48. package/dist/esm/abstract/BaseCompressionManager.js +373 -0
  49. package/dist/esm/abstract/BaseConnectionPool.js +539 -0
  50. package/dist/esm/abstract/BaseInterceptor.js +231 -0
  51. package/dist/esm/abstract/BaseLoadBalancer.js +265 -0
  52. package/dist/esm/abstract/BaseProtocol.js +265 -0
  53. package/dist/esm/abstract/BaseRetryStrategy.js +251 -0
  54. package/dist/esm/abstract/BaseSerializer.js +337 -0
  55. package/dist/esm/abstract/BaseServiceDiscoverer.js +250 -0
  56. package/dist/esm/abstract/BaseTimeoutManager.js +291 -0
  57. package/dist/esm/abstract/index.js +11 -0
  58. package/dist/esm/errors/CircuitBreakerError.js +12 -0
  59. package/dist/esm/errors/CommunicationError.js +11 -0
  60. package/dist/esm/errors/ConnectionError.js +11 -0
  61. package/dist/esm/errors/DiscoveryError.js +11 -0
  62. package/dist/esm/errors/LoadBalancerError.js +11 -0
  63. package/dist/esm/errors/ProtocolError.js +11 -0
  64. package/dist/esm/errors/RetryError.js +12 -0
  65. package/dist/esm/errors/SerializationError.js +11 -0
  66. package/dist/esm/errors/ServiceUnavailableError.js +11 -0
  67. package/dist/esm/errors/TimeoutError.js +12 -0
  68. package/dist/esm/errors/communicationErrorCodes.js +32 -0
  69. package/dist/esm/errors/index.js +17 -0
  70. package/dist/esm/index.js +18 -0
  71. package/dist/esm/interfaces/CircuitBreaker.interface.js +5 -0
  72. package/dist/esm/interfaces/Client.interface.js +5 -0
  73. package/dist/esm/interfaces/Compression.interface.js +5 -0
  74. package/dist/esm/interfaces/ConnectionPool.interface.js +5 -0
  75. package/dist/esm/interfaces/Interceptor.interface.js +5 -0
  76. package/dist/esm/interfaces/LoadBalancer.interface.js +1 -0
  77. package/dist/esm/interfaces/Protocol.interface.js +5 -0
  78. package/dist/esm/interfaces/RetryStrategy.interface.js +5 -0
  79. package/dist/esm/interfaces/Serializer.interface.js +1 -0
  80. package/dist/esm/interfaces/ServiceDiscovery.interface.js +5 -0
  81. package/dist/esm/interfaces/Timeout.interface.js +5 -0
  82. package/dist/esm/interfaces/index.js +5 -0
  83. package/dist/esm/types/config.js +5 -0
  84. package/dist/esm/types/events.js +5 -0
  85. package/dist/esm/types/index.js +5 -0
  86. package/dist/esm/types/request.js +5 -0
  87. package/dist/esm/types/response.js +5 -0
  88. package/dist/esm/types/service.js +5 -0
  89. package/dist/esm/utils.js +193 -0
  90. package/dist/types/abstract/BaseCircuitBreaker.d.ts +167 -0
  91. package/dist/types/abstract/BaseClient.d.ts +197 -0
  92. package/dist/types/abstract/BaseCompressionManager.d.ts +180 -0
  93. package/dist/types/abstract/BaseConnectionPool.d.ts +210 -0
  94. package/dist/types/abstract/BaseInterceptor.d.ts +150 -0
  95. package/dist/types/abstract/BaseLoadBalancer.d.ts +167 -0
  96. package/dist/types/abstract/BaseProtocol.d.ts +163 -0
  97. package/dist/types/abstract/BaseRetryStrategy.d.ts +130 -0
  98. package/dist/types/abstract/BaseSerializer.d.ts +181 -0
  99. package/dist/types/abstract/BaseServiceDiscoverer.d.ts +161 -0
  100. package/dist/types/abstract/BaseTimeoutManager.d.ts +145 -0
  101. package/dist/types/abstract/index.d.ts +11 -0
  102. package/dist/types/errors/CircuitBreakerError.d.ts +8 -0
  103. package/dist/types/errors/CommunicationError.d.ts +10 -0
  104. package/dist/types/errors/ConnectionError.d.ts +9 -0
  105. package/dist/types/errors/DiscoveryError.d.ts +9 -0
  106. package/dist/types/errors/LoadBalancerError.d.ts +9 -0
  107. package/dist/types/errors/ProtocolError.d.ts +9 -0
  108. package/dist/types/errors/RetryError.d.ts +11 -0
  109. package/dist/types/errors/SerializationError.d.ts +9 -0
  110. package/dist/types/errors/ServiceUnavailableError.d.ts +12 -0
  111. package/dist/types/errors/TimeoutError.d.ts +11 -0
  112. package/dist/types/errors/communicationErrorCodes.d.ts +27 -0
  113. package/dist/types/errors/index.d.ts +11 -0
  114. package/dist/types/index.d.ts +13 -0
  115. package/dist/types/interfaces/CircuitBreaker.interface.d.ts +150 -0
  116. package/dist/types/interfaces/Client.interface.d.ts +153 -0
  117. package/dist/types/interfaces/Compression.interface.d.ts +190 -0
  118. package/dist/types/interfaces/ConnectionPool.interface.d.ts +191 -0
  119. package/dist/types/interfaces/Interceptor.interface.d.ts +220 -0
  120. package/dist/types/interfaces/LoadBalancer.interface.d.ts +153 -0
  121. package/dist/types/interfaces/Protocol.interface.d.ts +117 -0
  122. package/dist/types/interfaces/RetryStrategy.interface.d.ts +160 -0
  123. package/dist/types/interfaces/Serializer.interface.d.ts +176 -0
  124. package/dist/types/interfaces/ServiceDiscovery.interface.d.ts +189 -0
  125. package/dist/types/interfaces/Timeout.interface.d.ts +135 -0
  126. package/dist/types/interfaces/index.d.ts +15 -0
  127. package/dist/types/types/config.d.ts +540 -0
  128. package/dist/types/types/events.d.ts +204 -0
  129. package/dist/types/types/index.d.ts +9 -0
  130. package/dist/types/types/request.d.ts +143 -0
  131. package/dist/types/types/response.d.ts +155 -0
  132. package/dist/types/types/service.d.ts +279 -0
  133. package/dist/types/utils.d.ts +179 -0
  134. package/package.json +88 -0
@@ -0,0 +1,540 @@
1
+ /**
2
+ * Configuration types for communication layer
3
+ * @packageDocumentation
4
+ */
5
+ /**
6
+ * HTTP methods
7
+ */
8
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
9
+ /**
10
+ * Protocol types supported
11
+ */
12
+ export type ProtocolType = 'http' | 'grpc' | 'websocket' | string;
13
+ /**
14
+ * Service discovery types
15
+ */
16
+ export type ServiceDiscoveryType = 'kubernetes' | 'consul' | 'eureka' | 'static' | 'custom';
17
+ /**
18
+ * Load balancing strategies
19
+ */
20
+ export type LoadBalanceStrategy = 'round-robin' | 'random' | 'weighted' | 'least-connections' | 'ip-hash' | 'custom';
21
+ /**
22
+ * Circuit breaker states
23
+ */
24
+ export type CircuitBreakerState = 'closed' | 'open' | 'half-open';
25
+ /**
26
+ * Backoff strategies for retry
27
+ */
28
+ export type BackoffStrategy = 'fixed' | 'exponential' | 'linear' | 'jitter' | 'fibonacci' | 'custom';
29
+ /**
30
+ * Serialization formats
31
+ */
32
+ export type SerializationFormat = 'json' | 'protobuf' | 'xml' | 'yaml' | 'msgpack' | 'custom';
33
+ /**
34
+ * Log levels for communication layer
35
+ */
36
+ export type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
37
+ /**
38
+ * Interceptor phase
39
+ */
40
+ export type InterceptorPhase = 'request' | 'response' | 'error';
41
+ /**
42
+ * Interceptor execution order
43
+ */
44
+ export interface InterceptorOrder {
45
+ /** Phase order within request phase */
46
+ request?: number;
47
+ /** Phase order within response phase */
48
+ response?: number;
49
+ /** Phase order within error phase */
50
+ error?: number;
51
+ }
52
+ /**
53
+ * Load balancer selection result
54
+ */
55
+ export interface LoadBalancerSelection {
56
+ /** Selected service instance */
57
+ selectedInstance: ServiceInstance;
58
+ /** All available instances */
59
+ availableInstances: ServiceInstance[];
60
+ /** Selection timestamp */
61
+ timestamp: number;
62
+ /** Selection duration in milliseconds */
63
+ selectionDuration: number;
64
+ /** Selection metadata */
65
+ metadata?: Record<string, unknown>;
66
+ }
67
+ /**
68
+ * Retry decision result
69
+ */
70
+ export interface RetryDecision {
71
+ /** Whether to retry */
72
+ shouldRetry: boolean;
73
+ /** Delay before next retry in milliseconds */
74
+ delay?: number;
75
+ /** Reason for decision */
76
+ reason?: string;
77
+ }
78
+ /**
79
+ * Retry context for each attempt
80
+ */
81
+ export interface RetryContext {
82
+ /** Current attempt number (starting from 1) */
83
+ attempt: number;
84
+ /** Maximum allowed attempts */
85
+ maxAttempts: number;
86
+ /** Last error that occurred */
87
+ lastError?: unknown;
88
+ /** Start time of first attempt */
89
+ startTime: number;
90
+ /** Total elapsed time in milliseconds */
91
+ elapsedTime: number;
92
+ /** Is this a retry attempt? */
93
+ isRetry: boolean;
94
+ /** Custom context data */
95
+ data?: Map<string, unknown>;
96
+ }
97
+ /**
98
+ * Serialization context
99
+ */
100
+ export interface SerializationContext {
101
+ /** Target format */
102
+ format: SerializationFormat;
103
+ /** Content type */
104
+ contentType?: string;
105
+ /** Character encoding */
106
+ encoding?: string;
107
+ /** Custom serialization options */
108
+ options?: Record<string, unknown>;
109
+ /** Request/response metadata */
110
+ metadata?: Record<string, unknown>;
111
+ }
112
+ /**
113
+ * Deserialization context
114
+ */
115
+ export interface DeserializationContext {
116
+ /** Source format */
117
+ format: SerializationFormat;
118
+ /** Content type */
119
+ contentType?: string;
120
+ /** Character encoding */
121
+ encoding?: string;
122
+ /** Target type (for type-safe deserialization) */
123
+ targetType?: unknown;
124
+ /** Custom deserialization options */
125
+ options?: Record<string, unknown>;
126
+ /** Request/response metadata */
127
+ metadata?: Record<string, unknown>;
128
+ }
129
+ /**
130
+ * Base configuration for all protocols
131
+ */
132
+ export interface BaseProtocolConfig {
133
+ /** Protocol name */
134
+ name: string;
135
+ /** Connection timeout in milliseconds */
136
+ timeout?: number;
137
+ /** Maximum connections */
138
+ maxConnections?: number;
139
+ /** Enable/disable keep-alive */
140
+ keepAlive?: boolean;
141
+ /** Keep-alive timeout in milliseconds */
142
+ keepAliveTimeout?: number;
143
+ /** Enable/disable compression */
144
+ compression?: boolean;
145
+ /** Custom protocol options */
146
+ options?: Record<string, unknown>;
147
+ }
148
+ /**
149
+ * HTTP protocol configuration
150
+ */
151
+ export interface HttpProtocolConfig extends BaseProtocolConfig {
152
+ /** Base URL */
153
+ baseUrl?: string;
154
+ /** Default headers */
155
+ defaultHeaders?: Record<string, string>;
156
+ /** Enable/disable automatic retry */
157
+ retry?: boolean;
158
+ /** Enable/disable automatic redirect */
159
+ redirect?: boolean;
160
+ /** With credentials for CORS */
161
+ withCredentials?: boolean;
162
+ /** Response type */
163
+ responseType?: 'json' | 'text' | 'arraybuffer' | 'blob' | 'stream';
164
+ /** Validate status function */
165
+ validateStatus?: (status: number) => boolean;
166
+ }
167
+ /**
168
+ * gRPC protocol configuration
169
+ */
170
+ export interface GrpcProtocolConfig extends BaseProtocolConfig {
171
+ /** gRPC endpoint */
172
+ endpoint: string;
173
+ /** Use SSL/TLS */
174
+ ssl?: boolean;
175
+ /** SSL/TLS certificate */
176
+ sslCert?: Buffer | string;
177
+ /** Keep-alive parameters */
178
+ keepAliveParams?: {
179
+ /** Keep-alive time in seconds */
180
+ keepaliveTime?: number;
181
+ /** Keep-alive timeout in seconds */
182
+ keepaliveTimeout?: number;
183
+ /** Keep-alive permit without calls */
184
+ keepalivePermitWithoutCalls?: boolean;
185
+ };
186
+ /** Maximum message size in bytes */
187
+ maxMessageSize?: number;
188
+ /** Maximum metadata size in bytes */
189
+ maxMetadataSize?: number;
190
+ }
191
+ /**
192
+ * WebSocket protocol configuration
193
+ */
194
+ export interface WebSocketProtocolConfig extends BaseProtocolConfig {
195
+ /** WebSocket URL */
196
+ url: string;
197
+ /** Protocols */
198
+ protocols?: string[];
199
+ /** Reconnection attempts */
200
+ reconnectAttempts?: number;
201
+ /** Reconnection delay in milliseconds */
202
+ reconnectDelay?: number;
203
+ /** Heartbeat interval in milliseconds */
204
+ heartbeatInterval?: number;
205
+ /** Heartbeat timeout in milliseconds */
206
+ heartbeatTimeout?: number;
207
+ /** Queue size for messages */
208
+ queueSize?: number;
209
+ }
210
+ /**
211
+ * Client configuration
212
+ */
213
+ export interface ClientConfig {
214
+ /** Service name */
215
+ serviceName: string;
216
+ /** Protocol configuration */
217
+ protocol?: BaseProtocolConfig;
218
+ /** Service discovery configuration */
219
+ discovery?: ServiceDiscoveryConfig;
220
+ /** Load balancing configuration */
221
+ loadBalancing?: LoadBalancingConfig;
222
+ /** Resilience configuration */
223
+ resilience?: ResilienceConfig;
224
+ /** Connection pool configuration */
225
+ connectionPool?: ConnectionPoolConfig;
226
+ /** Compression configuration */
227
+ compression?: CompressionConfig;
228
+ /** Rate limiting configuration */
229
+ rateLimit?: RateLimitConfig;
230
+ /** Interceptors */
231
+ interceptors?: InterceptorConfig[];
232
+ /** Serialization configuration */
233
+ serialization?: SerializationConfig;
234
+ /** Logging configuration */
235
+ logging?: LoggingConfig;
236
+ /** Metrics configuration */
237
+ metrics?: MetricsConfig;
238
+ /** Cache configuration */
239
+ cache?: CacheConfig;
240
+ /** Custom configuration */
241
+ custom?: Record<string, unknown>;
242
+ }
243
+ /**
244
+ * Service discovery configuration
245
+ */
246
+ export interface ServiceDiscoveryConfig {
247
+ /** Discovery type */
248
+ type: ServiceDiscoveryType;
249
+ /** Service discovery endpoint */
250
+ endpoint?: string;
251
+ /** Cache TTL in milliseconds */
252
+ cacheTTL?: number;
253
+ /** Health check interval in milliseconds */
254
+ healthCheckInterval?: number;
255
+ /** Health check timeout in milliseconds */
256
+ healthCheckTimeout?: number;
257
+ /** Custom discovery options */
258
+ options?: Record<string, unknown>;
259
+ }
260
+ /**
261
+ * Load balancing configuration
262
+ */
263
+ export interface LoadBalancingConfig {
264
+ /** Load balancing strategy */
265
+ strategy: LoadBalanceStrategy;
266
+ /** Instance weights (for weighted strategies) */
267
+ weights?: Record<string, number>;
268
+ /** Sticky sessions configuration */
269
+ sticky?: {
270
+ /** Enable sticky sessions */
271
+ enabled: boolean;
272
+ /** Session key */
273
+ key?: string;
274
+ /** Session TTL in milliseconds */
275
+ ttl?: number;
276
+ };
277
+ /** Custom load balancing options */
278
+ options?: Record<string, unknown>;
279
+ }
280
+ /**
281
+ * Resilience configuration
282
+ */
283
+ export interface ResilienceConfig {
284
+ /** Circuit breaker configuration */
285
+ circuitBreaker?: CircuitBreakerConfig;
286
+ /** Retry configuration */
287
+ retry?: RetryPolicyConfig;
288
+ /** Timeout configuration */
289
+ timeout?: TimeoutConfig;
290
+ /** Bulkhead configuration */
291
+ bulkhead?: BulkheadConfig;
292
+ /** Fallback configuration */
293
+ fallback?: FallbackConfig;
294
+ /** Rate limiting configuration */
295
+ rateLimit?: RateLimitConfig;
296
+ }
297
+ /**
298
+ * Circuit breaker configuration
299
+ */
300
+ export interface CircuitBreakerConfig {
301
+ /** Enable circuit breaker */
302
+ enabled?: boolean;
303
+ /** Failure threshold before opening */
304
+ failureThreshold?: number;
305
+ /** Success threshold before closing */
306
+ successThreshold?: number;
307
+ /** Reset timeout in milliseconds */
308
+ resetTimeout?: number;
309
+ /** Half-open max attempts */
310
+ halfOpenMaxAttempts?: number;
311
+ /** Excluded endpoints */
312
+ exclude?: string[];
313
+ /** Custom circuit breaker options */
314
+ options?: Record<string, unknown>;
315
+ }
316
+ /**
317
+ * Retry policy configuration
318
+ */
319
+ export interface RetryPolicyConfig {
320
+ /** Enable retry */
321
+ enabled?: boolean;
322
+ /** Maximum retry attempts */
323
+ maxAttempts?: number;
324
+ /** Backoff strategy */
325
+ backoffStrategy?: BackoffStrategy;
326
+ /** Backoff configuration */
327
+ backoff?: {
328
+ /** Initial delay in milliseconds */
329
+ initialDelay?: number;
330
+ /** Maximum delay in milliseconds */
331
+ maxDelay?: number;
332
+ /** Multiplier for exponential backoff */
333
+ multiplier?: number;
334
+ /** Jitter factor (0-1) */
335
+ jitter?: number;
336
+ /** Custom backoff function */
337
+ custom?: (attempt: number) => number;
338
+ };
339
+ /** Retry on specific status codes */
340
+ retryOnStatus?: number[];
341
+ /** Retry on specific error types */
342
+ retryOnErrors?: string[];
343
+ /** Custom retry options */
344
+ options?: Record<string, unknown>;
345
+ }
346
+ /**
347
+ * Timeout configuration
348
+ */
349
+ export interface TimeoutConfig {
350
+ /** Global timeout in milliseconds */
351
+ global?: number;
352
+ /** Connection timeout in milliseconds */
353
+ connection?: number;
354
+ /** Read timeout in milliseconds */
355
+ read?: number;
356
+ /** Write timeout in milliseconds */
357
+ write?: number;
358
+ /** Request timeout in milliseconds */
359
+ request?: number;
360
+ }
361
+ /**
362
+ * Bulkhead configuration
363
+ */
364
+ export interface BulkheadConfig {
365
+ /** Enable bulkhead */
366
+ enabled?: boolean;
367
+ /** Maximum concurrent executions */
368
+ maxConcurrent?: number;
369
+ /** Maximum queue size */
370
+ maxQueue?: number;
371
+ /** Queue timeout in milliseconds */
372
+ queueTimeout?: number;
373
+ }
374
+ /**
375
+ * Fallback configuration
376
+ */
377
+ export interface FallbackConfig {
378
+ /** Enable fallback */
379
+ enabled?: boolean;
380
+ /** Fallback function or value */
381
+ fallback?: unknown;
382
+ /** Fallback condition */
383
+ condition?: (error: Error) => boolean;
384
+ }
385
+ /**
386
+ * Interceptor configuration
387
+ */
388
+ export interface InterceptorConfig {
389
+ /** Interceptor type or function */
390
+ interceptor: string | Function;
391
+ /** Interceptor options */
392
+ options?: Record<string, unknown>;
393
+ /** Execution order */
394
+ order?: number;
395
+ }
396
+ /**
397
+ * Serialization configuration
398
+ */
399
+ export interface SerializationConfig {
400
+ /** Default serialization format */
401
+ format?: SerializationFormat;
402
+ /** Date parsing strategy */
403
+ dateParsing?: 'string' | 'date' | 'timestamp';
404
+ /** BigInt parsing strategy */
405
+ bigIntParsing?: 'string' | 'number' | 'bigint';
406
+ /** Custom serializers */
407
+ customSerializers?: Record<string, Function>;
408
+ /** Custom deserializers */
409
+ customDeserializers?: Record<string, Function>;
410
+ }
411
+ /**
412
+ * Logging configuration
413
+ */
414
+ export interface LoggingConfig {
415
+ /** Enable logging */
416
+ enabled?: boolean;
417
+ /** Log level */
418
+ level?: LogLevel;
419
+ /** Log format */
420
+ format?: 'json' | 'text' | 'custom';
421
+ /** Custom logger */
422
+ logger?: Function;
423
+ /** Log fields to include */
424
+ fields?: string[];
425
+ /** Redact sensitive fields */
426
+ redact?: string[];
427
+ }
428
+ /**
429
+ * Metrics configuration
430
+ */
431
+ export interface MetricsConfig {
432
+ /** Enable metrics */
433
+ enabled?: boolean;
434
+ /** Metrics collector */
435
+ collector?: Function;
436
+ /** Metrics prefix */
437
+ prefix?: string;
438
+ /** Custom labels */
439
+ labels?: Record<string, string>;
440
+ /** Histogram buckets */
441
+ buckets?: number[];
442
+ /** Metrics aggregation interval in milliseconds */
443
+ interval?: number;
444
+ }
445
+ /**
446
+ * Cache configuration
447
+ */
448
+ export interface CacheConfig {
449
+ /** Enable caching */
450
+ enabled?: boolean;
451
+ /** Cache TTL in milliseconds */
452
+ ttl?: number;
453
+ /** Cache key generator */
454
+ keyGenerator?: (request: unknown) => string;
455
+ /** Cache storage */
456
+ storage?: 'memory' | 'redis' | 'custom';
457
+ /** Cache storage options */
458
+ storageOptions?: Record<string, unknown>;
459
+ /** Cache invalidation strategy */
460
+ invalidation?: {
461
+ /** Invalidate on write operations */
462
+ onWrite?: boolean;
463
+ /** Invalidate after time */
464
+ afterTime?: number;
465
+ /** Custom invalidation function */
466
+ custom?: Function;
467
+ };
468
+ }
469
+ interface ServiceInstance {
470
+ id: string;
471
+ serviceName: string;
472
+ host: string;
473
+ port: number;
474
+ status: 'healthy' | 'unhealthy' | 'unknown';
475
+ [key: string]: unknown;
476
+ }
477
+ /**
478
+ * Connection pool configuration
479
+ */
480
+ export interface ConnectionPoolConfig {
481
+ /** Enable connection pooling */
482
+ enabled?: boolean;
483
+ /** Minimum connections in pool */
484
+ minConnections?: number;
485
+ /** Maximum connections in pool */
486
+ maxConnections?: number;
487
+ /** Connection idle timeout in milliseconds */
488
+ idleTimeout?: number;
489
+ /** Connection lifetime in milliseconds */
490
+ maxLifetime?: number;
491
+ /** Connection acquisition timeout in milliseconds */
492
+ acquireTimeout?: number;
493
+ /** Connection validation interval in milliseconds */
494
+ validationInterval?: number;
495
+ /** Enable connection warmup */
496
+ warmup?: boolean;
497
+ /** Custom pool options */
498
+ options?: Record<string, unknown>;
499
+ }
500
+ /**
501
+ * Compression configuration
502
+ */
503
+ export interface CompressionConfig {
504
+ /** Enable compression */
505
+ enabled?: boolean;
506
+ /** Compression algorithm */
507
+ algorithm?: 'gzip' | 'deflate' | 'brotli' | 'none';
508
+ /** Compression level (1-11) */
509
+ level?: number;
510
+ /** Minimum size to compress in bytes */
511
+ minSize?: number;
512
+ /** Maximum size to compress in bytes */
513
+ maxSize?: number;
514
+ /** Content types to compress */
515
+ contentTypes?: string[];
516
+ /** Custom compression options */
517
+ options?: Record<string, unknown>;
518
+ }
519
+ /**
520
+ * Rate limiting configuration
521
+ */
522
+ export interface RateLimitConfig {
523
+ /** Enable rate limiting */
524
+ enabled?: boolean;
525
+ /** Maximum requests per window */
526
+ maxRequests?: number;
527
+ /** Time window in milliseconds */
528
+ windowMs?: number;
529
+ /** Rate limit key generator */
530
+ keyGenerator?: (request: unknown) => string;
531
+ /** Skip successful requests */
532
+ skipSuccessfulRequests?: boolean;
533
+ /** Enable request queue */
534
+ queue?: boolean;
535
+ /** Maximum queue size */
536
+ maxQueueSize?: number;
537
+ /** Custom rate limit options */
538
+ options?: Record<string, unknown>;
539
+ }
540
+ export {};