@nest-omni/core 4.1.3-19 → 4.1.3-20
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/cache/cache.module.d.ts +0 -6
- package/cache/cache.module.js +7 -7
- package/cache/cache.service.js +12 -0
- package/cache/dependencies/db.dependency.d.ts +0 -13
- package/cache/dependencies/db.dependency.js +0 -16
- package/cache/dependencies/tag.dependency.d.ts +39 -4
- package/cache/dependencies/tag.dependency.js +109 -11
- package/cache/interfaces/cache-options.interface.d.ts +8 -0
- package/cache/providers/memory-cache.provider.d.ts +20 -0
- package/cache/providers/memory-cache.provider.js +40 -0
- package/http-client/config/http-client.config.d.ts +5 -0
- package/http-client/config/http-client.config.js +24 -13
- package/http-client/decorators/http-client.decorators.d.ts +1 -25
- package/http-client/decorators/http-client.decorators.js +97 -90
- package/http-client/entities/http-log.entity.d.ts +0 -20
- package/http-client/entities/http-log.entity.js +0 -12
- package/http-client/examples/advanced-usage.example.d.ts +4 -5
- package/http-client/examples/advanced-usage.example.js +4 -56
- package/http-client/http-client.module.d.ts +35 -2
- package/http-client/http-client.module.js +80 -75
- package/http-client/index.d.ts +1 -1
- package/http-client/interfaces/api-client-config.interface.d.ts +1 -91
- package/http-client/interfaces/http-client-config.interface.d.ts +53 -62
- package/http-client/services/api-client-registry.service.d.ts +5 -23
- package/http-client/services/api-client-registry.service.js +41 -284
- package/http-client/services/circuit-breaker.service.d.ts +69 -2
- package/http-client/services/circuit-breaker.service.js +185 -7
- package/http-client/services/http-client.service.d.ts +58 -23
- package/http-client/services/http-client.service.js +294 -150
- package/http-client/services/http-log-query.service.js +0 -13
- package/http-client/services/index.d.ts +0 -1
- package/http-client/services/index.js +0 -1
- package/http-client/services/logging.service.d.ts +79 -10
- package/http-client/services/logging.service.js +246 -51
- package/http-client/utils/call-stack-extractor.util.d.ts +26 -0
- package/http-client/utils/call-stack-extractor.util.js +35 -0
- package/http-client/utils/security-validator.util.d.ts +118 -0
- package/http-client/utils/security-validator.util.js +352 -0
- package/package.json +1 -1
- package/redis-lock/lock-heartbeat.service.d.ts +2 -0
- package/redis-lock/lock-heartbeat.service.js +12 -2
- package/redis-lock/redis-lock.service.d.ts +4 -0
- package/redis-lock/redis-lock.service.js +61 -8
- package/http-client/services/cache.service.d.ts +0 -76
- package/http-client/services/cache.service.js +0 -333
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
12
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
13
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,25 +38,70 @@ let HttpCircuitBreakerService = HttpCircuitBreakerService_1 = class HttpCircuitB
|
|
|
35
38
|
constructor() {
|
|
36
39
|
this.logger = new common_1.Logger(HttpCircuitBreakerService_1.name);
|
|
37
40
|
this.circuitBreakers = new Map();
|
|
41
|
+
/** 默认清理配置 */
|
|
42
|
+
this.cleanupConfig = {
|
|
43
|
+
maxIdleTimeMs: 30 * 60 * 1000, // 30分钟
|
|
44
|
+
cleanupIntervalMs: 5 * 60 * 1000, // 5分钟
|
|
45
|
+
maxSize: 1000, // 最多1000个circuit breaker
|
|
46
|
+
};
|
|
47
|
+
// 启动定期清理任务
|
|
48
|
+
this.startCleanupTask();
|
|
49
|
+
}
|
|
50
|
+
onModuleDestroy() {
|
|
51
|
+
// 清理定时器
|
|
52
|
+
if (this.cleanupTimer) {
|
|
53
|
+
clearInterval(this.cleanupTimer);
|
|
54
|
+
}
|
|
38
55
|
}
|
|
39
56
|
/**
|
|
40
57
|
* 获取或创建熔断器
|
|
41
58
|
*/
|
|
42
59
|
getCircuitBreaker(key, config) {
|
|
43
|
-
|
|
44
|
-
|
|
60
|
+
let circuitBreaker = this.circuitBreakers.get(key);
|
|
61
|
+
if (!circuitBreaker) {
|
|
62
|
+
this.logger.debug(`Creating new circuit breaker with key: ${key}`);
|
|
63
|
+
circuitBreaker = new CircuitBreaker(key, config, this.logger);
|
|
64
|
+
this.circuitBreakers.set(key, circuitBreaker);
|
|
65
|
+
// 检查是否超过最大数量,如果是则触发LRU清理
|
|
66
|
+
if (this.circuitBreakers.size > this.cleanupConfig.maxSize) {
|
|
67
|
+
this.cleanupLRU();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.logger.debug(`Reusing existing circuit breaker with key: ${key}`);
|
|
72
|
+
// 更新最后访问时间
|
|
73
|
+
circuitBreaker.updateLastAccessTime();
|
|
45
74
|
}
|
|
46
|
-
return
|
|
75
|
+
return circuitBreaker;
|
|
47
76
|
}
|
|
48
77
|
/**
|
|
49
78
|
* 执行带熔断保护的请求
|
|
50
79
|
*/
|
|
51
|
-
executeWithCircuitBreaker(key, requestFn, config) {
|
|
80
|
+
executeWithCircuitBreaker(key, requestFn, config, onStateChange) {
|
|
52
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
82
|
const circuitBreaker = this.getCircuitBreaker(key, config);
|
|
54
|
-
return circuitBreaker.execute(requestFn);
|
|
83
|
+
return circuitBreaker.execute(requestFn, onStateChange);
|
|
55
84
|
});
|
|
56
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* 获取熔断器当前状态
|
|
88
|
+
*/
|
|
89
|
+
getCircuitBreakerState(key) {
|
|
90
|
+
// Log all current circuit breaker keys for debugging
|
|
91
|
+
this.logger.debug(`Looking for circuit breaker key: ${key}. Available keys: [${Array.from(this.circuitBreakers.keys()).join(', ')}]`);
|
|
92
|
+
const circuitBreaker = this.circuitBreakers.get(key);
|
|
93
|
+
if (!circuitBreaker) {
|
|
94
|
+
this.logger.debug(`Circuit breaker not found for key: ${key}`);
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const state = circuitBreaker.getState();
|
|
98
|
+
if (!state) {
|
|
99
|
+
this.logger.debug(`Circuit breaker getState() returned undefined for key: ${key}`);
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
this.logger.debug(`Circuit breaker state for ${key}: ${state.state}`);
|
|
103
|
+
return state.state;
|
|
104
|
+
}
|
|
57
105
|
/**
|
|
58
106
|
* 重置所有熔断器
|
|
59
107
|
*/
|
|
@@ -70,10 +118,111 @@ let HttpCircuitBreakerService = HttpCircuitBreakerService_1 = class HttpCircuitB
|
|
|
70
118
|
});
|
|
71
119
|
return states;
|
|
72
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* 获取Circuit Breaker统计信息
|
|
123
|
+
*/
|
|
124
|
+
getStats() {
|
|
125
|
+
const stats = {
|
|
126
|
+
total: this.circuitBreakers.size,
|
|
127
|
+
byState: {
|
|
128
|
+
CLOSED: 0,
|
|
129
|
+
OPEN: 0,
|
|
130
|
+
HALF_OPEN: 0,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
this.circuitBreakers.forEach((cb) => {
|
|
134
|
+
const state = cb.getState();
|
|
135
|
+
if (state && state.state) {
|
|
136
|
+
stats.byState[state.state]++;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return stats;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 清理空闲的Circuit Breaker
|
|
143
|
+
* 清理超过最大空闲时间的Circuit Breaker
|
|
144
|
+
*/
|
|
145
|
+
cleanupIdle() {
|
|
146
|
+
const now = Date.now();
|
|
147
|
+
const keysToDelete = [];
|
|
148
|
+
this.circuitBreakers.forEach((cb, key) => {
|
|
149
|
+
const lastAccess = cb.getLastAccessTime();
|
|
150
|
+
if (now - lastAccess > this.cleanupConfig.maxIdleTimeMs) {
|
|
151
|
+
keysToDelete.push(key);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
keysToDelete.forEach((key) => {
|
|
155
|
+
this.circuitBreakers.delete(key);
|
|
156
|
+
this.logger.debug(`Removed idle circuit breaker: ${key}`);
|
|
157
|
+
});
|
|
158
|
+
if (keysToDelete.length > 0) {
|
|
159
|
+
this.logger.log(`Cleaned up ${keysToDelete.length} idle circuit breaker(s)`);
|
|
160
|
+
}
|
|
161
|
+
return keysToDelete.length;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 基于LRU策略清理Circuit Breaker
|
|
165
|
+
* 删除最久未访问的Circuit Breaker直到数量降到maxSize以下
|
|
166
|
+
*/
|
|
167
|
+
cleanupLRU() {
|
|
168
|
+
const entries = Array.from(this.circuitBreakers.entries());
|
|
169
|
+
// 按最后访问时间排序(最老的在前)
|
|
170
|
+
entries.sort((a, b) => {
|
|
171
|
+
return a[1].getLastAccessTime() - b[1].getLastAccessTime();
|
|
172
|
+
});
|
|
173
|
+
// 计算需要删除的数量
|
|
174
|
+
const toDelete = entries.slice(0, entries.length - this.cleanupConfig.maxSize);
|
|
175
|
+
toDelete.forEach(([key]) => {
|
|
176
|
+
this.circuitBreakers.delete(key);
|
|
177
|
+
this.logger.debug(`Removed LRU circuit breaker: ${key}`);
|
|
178
|
+
});
|
|
179
|
+
if (toDelete.length > 0) {
|
|
180
|
+
this.logger.warn(`LRU cleanup: removed ${toDelete.length} circuit breaker(s) to maintain max size of ${this.cleanupConfig.maxSize}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 启动定期清理任务
|
|
185
|
+
*/
|
|
186
|
+
startCleanupTask() {
|
|
187
|
+
this.cleanupTimer = setInterval(() => {
|
|
188
|
+
try {
|
|
189
|
+
this.cleanupIdle();
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
this.logger.error('Error during circuit breaker cleanup', error);
|
|
193
|
+
}
|
|
194
|
+
}, this.cleanupConfig.cleanupIntervalMs);
|
|
195
|
+
this.logger.log(`Circuit breaker cleanup task started (interval: ${this.cleanupConfig.cleanupIntervalMs}ms, maxIdleTime: ${this.cleanupConfig.maxIdleTimeMs}ms)`);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 手动触发清理(用于测试)
|
|
199
|
+
*/
|
|
200
|
+
manualCleanup() {
|
|
201
|
+
return this.cleanupIdle();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 设置清理配置
|
|
205
|
+
*/
|
|
206
|
+
setCleanupConfig(config) {
|
|
207
|
+
Object.assign(this.cleanupConfig, config);
|
|
208
|
+
// 重启清理任务
|
|
209
|
+
if (this.cleanupTimer) {
|
|
210
|
+
clearInterval(this.cleanupTimer);
|
|
211
|
+
}
|
|
212
|
+
this.startCleanupTask();
|
|
213
|
+
this.logger.log(`Circuit breaker cleanup config updated: ${JSON.stringify(this.cleanupConfig)}`);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 获取清理配置
|
|
217
|
+
*/
|
|
218
|
+
getCleanupConfig() {
|
|
219
|
+
return Object.assign({}, this.cleanupConfig);
|
|
220
|
+
}
|
|
73
221
|
};
|
|
74
222
|
exports.HttpCircuitBreakerService = HttpCircuitBreakerService;
|
|
75
223
|
exports.HttpCircuitBreakerService = HttpCircuitBreakerService = HttpCircuitBreakerService_1 = __decorate([
|
|
76
|
-
(0, common_1.Injectable)()
|
|
224
|
+
(0, common_1.Injectable)(),
|
|
225
|
+
__metadata("design:paramtypes", [])
|
|
77
226
|
], HttpCircuitBreakerService);
|
|
78
227
|
/**
|
|
79
228
|
* 熔断器类
|
|
@@ -90,12 +239,27 @@ class CircuitBreaker {
|
|
|
90
239
|
this.nextAttemptTime = 0;
|
|
91
240
|
this.requestCount = 0;
|
|
92
241
|
this.windowStartTime = Date.now();
|
|
242
|
+
this.lastAccessTime = Date.now(); // 添加最后访问时间跟踪
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 更新最后访问时间
|
|
246
|
+
*/
|
|
247
|
+
updateLastAccessTime() {
|
|
248
|
+
this.lastAccessTime = Date.now();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 获取最后访问时间
|
|
252
|
+
*/
|
|
253
|
+
getLastAccessTime() {
|
|
254
|
+
return this.lastAccessTime;
|
|
93
255
|
}
|
|
94
256
|
/**
|
|
95
257
|
* 执行请求
|
|
96
258
|
*/
|
|
97
|
-
execute(requestFn) {
|
|
259
|
+
execute(requestFn, onStateChange) {
|
|
98
260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
// 保存状态变化回调
|
|
262
|
+
this.onStateChange = onStateChange;
|
|
99
263
|
const currentTime = Date.now();
|
|
100
264
|
// 检查是否需要重置监控窗口
|
|
101
265
|
if (currentTime - this.windowStartTime > this.config.monitoringPeriodMs) {
|
|
@@ -197,6 +361,8 @@ class CircuitBreaker {
|
|
|
197
361
|
this.state = CircuitBreakerState.CLOSED;
|
|
198
362
|
this.failureCount = 0;
|
|
199
363
|
this.successCount = 0;
|
|
364
|
+
// 通知状态变化
|
|
365
|
+
this.notifyStateChange(CircuitBreakerState.CLOSED);
|
|
200
366
|
}
|
|
201
367
|
}
|
|
202
368
|
/**
|
|
@@ -208,6 +374,8 @@ class CircuitBreaker {
|
|
|
208
374
|
this.state = CircuitBreakerState.OPEN;
|
|
209
375
|
this.nextAttemptTime = Date.now() + this.config.recoveryTimeoutMs;
|
|
210
376
|
this.successCount = 0;
|
|
377
|
+
// 通知状态变化
|
|
378
|
+
this.notifyStateChange(CircuitBreakerState.OPEN);
|
|
211
379
|
}
|
|
212
380
|
}
|
|
213
381
|
/**
|
|
@@ -218,6 +386,16 @@ class CircuitBreaker {
|
|
|
218
386
|
this.logger.log(`Circuit breaker ${this.key} transitioned to HALF_OPEN`);
|
|
219
387
|
this.state = CircuitBreakerState.HALF_OPEN;
|
|
220
388
|
this.successCount = 0;
|
|
389
|
+
// 通知状态变化
|
|
390
|
+
this.notifyStateChange(CircuitBreakerState.HALF_OPEN);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* 通知状态变化
|
|
395
|
+
*/
|
|
396
|
+
notifyStateChange(state) {
|
|
397
|
+
if (this.onStateChange) {
|
|
398
|
+
this.onStateChange(state);
|
|
221
399
|
}
|
|
222
400
|
}
|
|
223
401
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
import { HttpClientConfig } from '../interfaces/http-client-config.interface';
|
|
3
|
+
import { AuthType, ApiKeyConfig, BasicAuthConfig, BearerTokenConfig, CustomAuthConfig, OAuth2Config } from '../interfaces/api-client-config.interface';
|
|
3
4
|
import { HttpCircuitBreakerService } from './circuit-breaker.service';
|
|
4
5
|
import { HttpLoggingService } from './logging.service';
|
|
5
|
-
import { HttpCacheService } from './cache.service';
|
|
6
6
|
import { RedisLockService } from '../../redis-lock/redis-lock.service';
|
|
7
7
|
interface ExtendedAxiosRequestConfig extends AxiosRequestConfig {
|
|
8
8
|
metadata?: {
|
|
@@ -11,24 +11,52 @@ interface ExtendedAxiosRequestConfig extends AxiosRequestConfig {
|
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* 认证配置接口
|
|
16
|
+
*/
|
|
17
|
+
interface AuthConfig {
|
|
18
|
+
type: AuthType;
|
|
19
|
+
config?: ApiKeyConfig | BasicAuthConfig | BearerTokenConfig | OAuth2Config | CustomAuthConfig;
|
|
20
|
+
}
|
|
14
21
|
/**
|
|
15
22
|
* HTTP客户端服务
|
|
16
23
|
* 基于Spring RestTemplate的设计理念,集成axios-retry库
|
|
24
|
+
* 支持两种创建模式:
|
|
25
|
+
* 1. 直接创建: 用于简单的HTTP请求场景
|
|
26
|
+
* 2. API客户端模式: 用于需要认证、统计等高级功能的API客户端
|
|
17
27
|
*/
|
|
18
28
|
export declare class HttpClientService {
|
|
19
29
|
private readonly circuitBreakerService;
|
|
20
30
|
private readonly loggingService;
|
|
21
|
-
private readonly cacheService;
|
|
22
31
|
private readonly redisLockService?;
|
|
23
32
|
private readonly logger;
|
|
24
33
|
private readonly axiosInstance;
|
|
25
34
|
private readonly defaultConfig;
|
|
35
|
+
private readonly authConfig?;
|
|
36
|
+
private readonly clientName?;
|
|
26
37
|
private requestStats;
|
|
27
|
-
constructor(circuitBreakerService: HttpCircuitBreakerService, loggingService: HttpLoggingService,
|
|
38
|
+
constructor(circuitBreakerService: HttpCircuitBreakerService, loggingService: HttpLoggingService, redisLockService?: RedisLockService, config?: HttpClientConfig, clientName?: string, authConfig?: AuthConfig);
|
|
39
|
+
/**
|
|
40
|
+
* 静态工厂方法:创建API客户端模式的 HttpClientService
|
|
41
|
+
* @param dependencies 依赖服务
|
|
42
|
+
* @param config API客户端配置
|
|
43
|
+
* @returns HttpClientService 实例
|
|
44
|
+
*/
|
|
45
|
+
static createApiClient(dependencies: {
|
|
46
|
+
circuitBreakerService: HttpCircuitBreakerService;
|
|
47
|
+
loggingService: HttpLoggingService;
|
|
48
|
+
redisLockService?: RedisLockService;
|
|
49
|
+
}, config: {
|
|
50
|
+
name: string;
|
|
51
|
+
baseURL?: string;
|
|
52
|
+
timeout?: number;
|
|
53
|
+
httpConfig?: HttpClientConfig;
|
|
54
|
+
auth?: AuthConfig;
|
|
55
|
+
}): HttpClientService;
|
|
28
56
|
/**
|
|
29
57
|
* 执行HTTP请求
|
|
30
58
|
*/
|
|
31
|
-
request<T = any>(config: ExtendedAxiosRequestConfig, decoratorContext?: any): Promise<T>;
|
|
59
|
+
request<T = any>(config: ExtendedAxiosRequestConfig, decoratorContext?: any, clientName?: string): Promise<T>;
|
|
32
60
|
/**
|
|
33
61
|
* 生成curl命令(动态生成,不存储)
|
|
34
62
|
*/
|
|
@@ -45,11 +73,20 @@ export declare class HttpClientService {
|
|
|
45
73
|
* 重置统计信息
|
|
46
74
|
*/
|
|
47
75
|
resetStats(): void;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
76
|
+
/**
|
|
77
|
+
* 获取客户端名称
|
|
78
|
+
*/
|
|
79
|
+
getName(): string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Capture calling context information
|
|
82
|
+
* @returns Calling context with service class and method name
|
|
83
|
+
*/
|
|
84
|
+
private captureCallingContext;
|
|
85
|
+
get<T = any>(url: string, config?: AxiosRequestConfig, clientName?: string): Promise<T>;
|
|
86
|
+
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig, clientName?: string): Promise<T>;
|
|
87
|
+
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig, clientName?: string): Promise<T>;
|
|
88
|
+
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig, clientName?: string): Promise<T>;
|
|
89
|
+
delete<T = any>(url: string, config?: AxiosRequestConfig, clientName?: string): Promise<T>;
|
|
53
90
|
/**
|
|
54
91
|
* 带等待锁的认证请求方法
|
|
55
92
|
* 用于需要确保只有一个进程执行认证相关操作的场景
|
|
@@ -64,7 +101,7 @@ export declare class HttpClientService {
|
|
|
64
101
|
lockTimeout?: number;
|
|
65
102
|
waitTimeout?: number;
|
|
66
103
|
enableRetry?: boolean;
|
|
67
|
-
}): Promise<T>;
|
|
104
|
+
}, clientName?: string): Promise<T>;
|
|
68
105
|
/**
|
|
69
106
|
* 带等待锁的批量认证请求
|
|
70
107
|
* 用于需要批量执行认证相关操作但避免重复认证的场景
|
|
@@ -82,13 +119,14 @@ export declare class HttpClientService {
|
|
|
82
119
|
lockTimeout?: number;
|
|
83
120
|
waitTimeout?: number;
|
|
84
121
|
maxConcurrency?: number;
|
|
85
|
-
}): Promise<Array<T | null>>;
|
|
122
|
+
}, clientName?: string): Promise<Array<T | null>>;
|
|
86
123
|
/**
|
|
87
124
|
* 创建Axios实例并配置axios-retry
|
|
88
125
|
*/
|
|
89
126
|
private createAxiosInstance;
|
|
90
127
|
/**
|
|
91
128
|
* 执行带特性的请求(重试、熔断器等)
|
|
129
|
+
* 返回响应和熔断器状态
|
|
92
130
|
*/
|
|
93
131
|
private executeWithFeatures;
|
|
94
132
|
/**
|
|
@@ -99,22 +137,10 @@ export declare class HttpClientService {
|
|
|
99
137
|
* 应用装饰器配置
|
|
100
138
|
*/
|
|
101
139
|
private applyDecoratorConfig;
|
|
102
|
-
/**
|
|
103
|
-
* 判断是否应该缓存请求
|
|
104
|
-
*/
|
|
105
|
-
private shouldCacheRequest;
|
|
106
140
|
/**
|
|
107
141
|
* 生成熔断器键
|
|
108
142
|
*/
|
|
109
143
|
private generateCircuitBreakerKey;
|
|
110
|
-
/**
|
|
111
|
-
* 更新请求统计
|
|
112
|
-
*/
|
|
113
|
-
private updateStats;
|
|
114
|
-
/**
|
|
115
|
-
* 更新错误统计
|
|
116
|
-
*/
|
|
117
|
-
private updateErrorStats;
|
|
118
144
|
/**
|
|
119
145
|
* 合并默认配置
|
|
120
146
|
*/
|
|
@@ -131,5 +157,14 @@ export declare class HttpClientService {
|
|
|
131
157
|
* @returns 解析后的代理配置,如果不应使用代理则返回 false 或 undefined
|
|
132
158
|
*/
|
|
133
159
|
private resolveProxyConfig;
|
|
160
|
+
/**
|
|
161
|
+
* 应用认证配置到请求配置
|
|
162
|
+
*/
|
|
163
|
+
private applyAuthToConfig;
|
|
164
|
+
/**
|
|
165
|
+
* 更新请求统计信息
|
|
166
|
+
* 统一管理所有统计,避免在拦截器中重复统计
|
|
167
|
+
*/
|
|
168
|
+
private updateRequestStats;
|
|
134
169
|
}
|
|
135
170
|
export {};
|