@midwayjs/core 3.13.7 → 3.14.3

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.
@@ -1,12 +1,15 @@
1
1
  import { ModuleLoadType, DataSourceManagerConfigOption } from '../interface';
2
2
  import { MidwayEnvironmentService } from '../service/environmentService';
3
+ import { MidwayPriorityManager } from './priorityManager';
3
4
  export declare abstract class DataSourceManager<T, ConnectionOpts extends Record<string, any> = Record<string, any>> {
4
5
  protected dataSource: Map<string, T>;
5
6
  protected options: DataSourceManagerConfigOption<ConnectionOpts>;
6
7
  protected modelMapping: WeakMap<object, any>;
7
8
  private innerDefaultDataSourceName;
8
- appDir: string;
9
- environmentService: MidwayEnvironmentService;
9
+ protected dataSourcePriority: Record<string, string>;
10
+ protected appDir: string;
11
+ protected environmentService: MidwayEnvironmentService;
12
+ protected priorityManager: MidwayPriorityManager;
10
13
  protected initDataSource(dataSourceConfig: DataSourceManagerConfigOption<ConnectionOpts>, baseDirOrOptions: {
11
14
  baseDir: string;
12
15
  entitiesConfigKey?: string;
@@ -22,6 +25,7 @@ export declare abstract class DataSourceManager<T, ConnectionOpts extends Record
22
25
  */
23
26
  hasDataSource(dataSourceName: string): boolean;
24
27
  getDataSourceNames(): string[];
28
+ getAllDataSources(): Map<string, T>;
25
29
  /**
26
30
  * check the data source is connected
27
31
  * @param dataSourceName
@@ -42,6 +46,10 @@ export declare abstract class DataSourceManager<T, ConnectionOpts extends Record
42
46
  protected abstract destroyDataSource(dataSource: T): Promise<void>;
43
47
  stop(): Promise<void>;
44
48
  getDefaultDataSourceName(): string;
49
+ getDataSourcePriority(name: string): string;
50
+ isHighPriority(name: string): boolean;
51
+ isMediumPriority(name: string): boolean;
52
+ isLowPriority(name: string): boolean;
45
53
  }
46
54
  export declare function formatGlobString(globString: string): string[];
47
55
  export declare function globModels(globString: string, appDir: string, loadMode?: ModuleLoadType): Promise<any[]>;
@@ -23,6 +23,7 @@ const util_1 = require("util");
23
23
  const util_2 = require("../util");
24
24
  const decorator_1 = require("../decorator");
25
25
  const environmentService_1 = require("../service/environmentService");
26
+ const priorityManager_1 = require("./priorityManager");
26
27
  const debug = (0, util_1.debuglog)('midway:debug');
27
28
  class DataSourceManager {
28
29
  constructor() {
@@ -92,6 +93,9 @@ class DataSourceManager {
92
93
  getDataSourceNames() {
93
94
  return Array.from(this.dataSource.keys());
94
95
  }
96
+ getAllDataSources() {
97
+ return this.dataSource;
98
+ }
95
99
  /**
96
100
  * check the data source is connected
97
101
  * @param dataSourceName
@@ -152,6 +156,18 @@ class DataSourceManager {
152
156
  }
153
157
  return this.innerDefaultDataSourceName;
154
158
  }
159
+ getDataSourcePriority(name) {
160
+ return this.priorityManager.getPriority(this.dataSourcePriority[name]);
161
+ }
162
+ isHighPriority(name) {
163
+ return this.priorityManager.isHighPriority(this.dataSourcePriority[name]);
164
+ }
165
+ isMediumPriority(name) {
166
+ return this.priorityManager.isMediumPriority(this.dataSourcePriority[name]);
167
+ }
168
+ isLowPriority(name) {
169
+ return this.priorityManager.isLowPriority(this.dataSourcePriority[name]);
170
+ }
155
171
  }
156
172
  __decorate([
157
173
  (0, decorator_1.Inject)(),
@@ -161,6 +177,10 @@ __decorate([
161
177
  (0, decorator_1.Inject)(),
162
178
  __metadata("design:type", environmentService_1.MidwayEnvironmentService)
163
179
  ], DataSourceManager.prototype, "environmentService", void 0);
180
+ __decorate([
181
+ (0, decorator_1.Inject)(),
182
+ __metadata("design:type", priorityManager_1.MidwayPriorityManager)
183
+ ], DataSourceManager.prototype, "priorityManager", void 0);
164
184
  exports.DataSourceManager = DataSourceManager;
165
185
  function formatGlobString(globString) {
166
186
  let pattern;
@@ -15,6 +15,7 @@ export declare abstract class LoggerFactory<Logger extends ILogger, LoggerOption
15
15
  abstract createContextLogger(ctx: any, appLogger: ILogger, contextOptions?: any): ILogger;
16
16
  }
17
17
  export declare class DefaultConsoleLoggerFactory implements LoggerFactory<ILogger, any> {
18
+ private instance;
18
19
  createLogger(name: string, options: any): ILogger;
19
20
  getLogger(loggerName: string): ILogger;
20
21
  close(loggerName?: string): void;
@@ -28,5 +29,7 @@ export declare class DefaultConsoleLoggerFactory implements LoggerFactory<ILogge
28
29
  };
29
30
  };
30
31
  createContextLogger(ctx: any, appLogger: ILogger): ILogger;
32
+ getClients(): Map<string, ILogger>;
33
+ getClientKeys(): string[];
31
34
  }
32
35
  //# sourceMappingURL=loggerFactory.d.ts.map
@@ -5,11 +5,15 @@ class LoggerFactory {
5
5
  }
6
6
  exports.LoggerFactory = LoggerFactory;
7
7
  class DefaultConsoleLoggerFactory {
8
+ constructor() {
9
+ this.instance = new Map();
10
+ }
8
11
  createLogger(name, options) {
12
+ this.instance.set(name, console);
9
13
  return console;
10
14
  }
11
15
  getLogger(loggerName) {
12
- return console;
16
+ return this.instance.get(loggerName);
13
17
  }
14
18
  close(loggerName) { }
15
19
  removeLogger(loggerName) { }
@@ -27,6 +31,12 @@ class DefaultConsoleLoggerFactory {
27
31
  createContextLogger(ctx, appLogger) {
28
32
  return appLogger;
29
33
  }
34
+ getClients() {
35
+ return this.instance;
36
+ }
37
+ getClientKeys() {
38
+ return Array.from(this.instance.keys());
39
+ }
30
40
  }
31
41
  exports.DefaultConsoleLoggerFactory = DefaultConsoleLoggerFactory;
32
42
  //# sourceMappingURL=loggerFactory.js.map
@@ -0,0 +1,16 @@
1
+ export declare const DEFAULT_PRIORITY: {
2
+ L1: string;
3
+ L2: string;
4
+ L3: string;
5
+ };
6
+ export declare class MidwayPriorityManager {
7
+ private priorityList;
8
+ private defaultPriority;
9
+ getCurrentPriorityList(): Record<string, string>;
10
+ getDefaultPriority(): string;
11
+ isHighPriority(priority?: string): boolean;
12
+ isMediumPriority(priority?: string): boolean;
13
+ isLowPriority(priority?: string): boolean;
14
+ getPriority(priority: string): string;
15
+ }
16
+ //# sourceMappingURL=priorityManager.d.ts.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.MidwayPriorityManager = exports.DEFAULT_PRIORITY = void 0;
10
+ const decorator_1 = require("../decorator");
11
+ const interface_1 = require("../interface");
12
+ exports.DEFAULT_PRIORITY = {
13
+ L1: 'High',
14
+ L2: 'Medium',
15
+ L3: 'Low',
16
+ };
17
+ let MidwayPriorityManager = class MidwayPriorityManager {
18
+ constructor() {
19
+ this.priorityList = exports.DEFAULT_PRIORITY;
20
+ this.defaultPriority = exports.DEFAULT_PRIORITY.L2;
21
+ }
22
+ getCurrentPriorityList() {
23
+ return this.priorityList;
24
+ }
25
+ getDefaultPriority() {
26
+ return this.defaultPriority;
27
+ }
28
+ isHighPriority(priority = exports.DEFAULT_PRIORITY.L2) {
29
+ return priority === exports.DEFAULT_PRIORITY.L1;
30
+ }
31
+ isMediumPriority(priority = exports.DEFAULT_PRIORITY.L2) {
32
+ return priority === exports.DEFAULT_PRIORITY.L2;
33
+ }
34
+ isLowPriority(priority = exports.DEFAULT_PRIORITY.L2) {
35
+ return priority === exports.DEFAULT_PRIORITY.L3;
36
+ }
37
+ getPriority(priority) {
38
+ return priority || this.getDefaultPriority();
39
+ }
40
+ };
41
+ MidwayPriorityManager = __decorate([
42
+ (0, decorator_1.Provide)(),
43
+ (0, decorator_1.Scope)(interface_1.ScopeEnum.Singleton)
44
+ ], MidwayPriorityManager);
45
+ exports.MidwayPriorityManager = MidwayPriorityManager;
46
+ //# sourceMappingURL=priorityManager.js.map
@@ -1,10 +1,13 @@
1
1
  import { IServiceFactory } from '../interface';
2
+ import { MidwayPriorityManager } from './priorityManager';
2
3
  /**
3
4
  * 多客户端工厂实现
4
5
  */
5
6
  export declare abstract class ServiceFactory<T> implements IServiceFactory<T> {
6
7
  protected clients: Map<string, T>;
8
+ protected clientPriority: Record<string, string>;
7
9
  protected options: {};
10
+ protected priorityManager: MidwayPriorityManager;
8
11
  protected initClients(options?: any): Promise<void>;
9
12
  get<U = T>(id?: string): U;
10
13
  has(id: string): boolean;
@@ -14,5 +17,11 @@ export declare abstract class ServiceFactory<T> implements IServiceFactory<T> {
14
17
  protected destroyClient(client: T): Promise<void>;
15
18
  stop(): Promise<void>;
16
19
  getDefaultClientName(): string;
20
+ getClients(): Map<string, T>;
21
+ getClientKeys(): string[];
22
+ getClientPriority(name: string): string;
23
+ isHighPriority(name: string): boolean;
24
+ isMediumPriority(name: string): boolean;
25
+ isLowPriority(name: string): boolean;
17
26
  }
18
27
  //# sourceMappingURL=serviceFactory.d.ts.map
@@ -1,7 +1,18 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
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
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.ServiceFactory = void 0;
4
13
  const extend_1 = require("../util/extend");
14
+ const priorityManager_1 = require("./priorityManager");
15
+ const decorator_1 = require("../decorator");
5
16
  /**
6
17
  * 多客户端工厂实现
7
18
  */
@@ -24,6 +35,8 @@ class ServiceFactory {
24
35
  await this.createInstance(options.clients[id], id);
25
36
  }
26
37
  }
38
+ // set priority
39
+ this.clientPriority = options.priority || {};
27
40
  }
28
41
  get(id = 'default') {
29
42
  return this.clients.get(id);
@@ -51,6 +64,28 @@ class ServiceFactory {
51
64
  getDefaultClientName() {
52
65
  return this.options['defaultClientName'];
53
66
  }
67
+ getClients() {
68
+ return this.clients;
69
+ }
70
+ getClientKeys() {
71
+ return Array.from(this.clients.keys());
72
+ }
73
+ getClientPriority(name) {
74
+ return this.priorityManager.getPriority(this.clientPriority[name]);
75
+ }
76
+ isHighPriority(name) {
77
+ return this.priorityManager.isHighPriority(this.clientPriority[name]);
78
+ }
79
+ isMediumPriority(name) {
80
+ return this.priorityManager.isMediumPriority(this.clientPriority[name]);
81
+ }
82
+ isLowPriority(name) {
83
+ return this.priorityManager.isLowPriority(this.clientPriority[name]);
84
+ }
54
85
  }
86
+ __decorate([
87
+ (0, decorator_1.Inject)(),
88
+ __metadata("design:type", priorityManager_1.MidwayPriorityManager)
89
+ ], ServiceFactory.prototype, "priorityManager", void 0);
55
90
  exports.ServiceFactory = ServiceFactory;
56
91
  //# sourceMappingURL=serviceFactory.js.map
@@ -22,6 +22,7 @@ export declare const FrameworkErrorEnum: {
22
22
  readonly INVOKE_METHOD_FORBIDDEN: "MIDWAY_10018";
23
23
  readonly CODE_INVOKE_TIMEOUT: "MIDWAY_10019";
24
24
  readonly MAIN_FRAMEWORK_MISSING: "MIDWAY_10020";
25
+ readonly INVALID_CONFIG_PROPERTY: "MIDWAY_10021";
25
26
  };
26
27
  export declare class MidwayCommonError extends MidwayError {
27
28
  constructor(message: string);
@@ -86,4 +87,7 @@ export declare class MidwayCodeInvokeTimeoutError extends MidwayError {
86
87
  export declare class MidwayMainFrameworkMissingError extends MidwayError {
87
88
  constructor();
88
89
  }
90
+ export declare class MidwayInvalidConfigPropertyError extends MidwayError {
91
+ constructor(propertyName: string, allowTypes?: string[]);
92
+ }
89
93
  //# sourceMappingURL=framework.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MidwayMainFrameworkMissingError = exports.MidwayCodeInvokeTimeoutError = exports.MidwayInvokeForbiddenError = exports.MidwayRetryExceededMaxTimesError = exports.MidwayDuplicateControllerOptionsError = exports.MidwayDuplicateClassNameError = exports.MidwayInconsistentVersionError = exports.MidwayUtilHttpClientTimeoutError = exports.MidwayMissingImportComponentError = exports.MidwaySingletonInjectRequestError = exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayInvalidConfigError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
3
+ exports.MidwayInvalidConfigPropertyError = exports.MidwayMainFrameworkMissingError = exports.MidwayCodeInvokeTimeoutError = exports.MidwayInvokeForbiddenError = exports.MidwayRetryExceededMaxTimesError = exports.MidwayDuplicateControllerOptionsError = exports.MidwayDuplicateClassNameError = exports.MidwayInconsistentVersionError = exports.MidwayUtilHttpClientTimeoutError = exports.MidwayMissingImportComponentError = exports.MidwaySingletonInjectRequestError = exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayInvalidConfigError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
4
4
  const base_1 = require("./base");
5
5
  exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
6
6
  UNKNOWN: 10000,
@@ -24,6 +24,7 @@ exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
24
24
  INVOKE_METHOD_FORBIDDEN: 10018,
25
25
  CODE_INVOKE_TIMEOUT: 10019,
26
26
  MAIN_FRAMEWORK_MISSING: 10020,
27
+ INVALID_CONFIG_PROPERTY: 10021,
27
28
  });
28
29
  class MidwayCommonError extends base_1.MidwayError {
29
30
  constructor(message) {
@@ -166,4 +167,12 @@ class MidwayMainFrameworkMissingError extends base_1.MidwayError {
166
167
  }
167
168
  }
168
169
  exports.MidwayMainFrameworkMissingError = MidwayMainFrameworkMissingError;
170
+ class MidwayInvalidConfigPropertyError extends base_1.MidwayError {
171
+ constructor(propertyName, allowTypes) {
172
+ super(`Invalid config property "${propertyName}", ${allowTypes
173
+ ? `only ${allowTypes.join(',')} can be set`
174
+ : 'please check your configuration'}.`, exports.FrameworkErrorEnum.INVALID_CONFIG_PROPERTY);
175
+ }
176
+ }
177
+ exports.MidwayInvalidConfigPropertyError = MidwayInvalidConfigPropertyError;
169
178
  //# sourceMappingURL=framework.js.map
package/dist/index.d.ts CHANGED
@@ -15,9 +15,11 @@ export { MidwayLifeCycleService } from './service/lifeCycleService';
15
15
  export { MidwayMiddlewareService } from './service/middlewareService';
16
16
  export { MidwayDecoratorService } from './service/decoratorService';
17
17
  export { MidwayMockService } from './service/mockService';
18
+ export { MidwayHealthService } from './service/healthService';
18
19
  export { RouterInfo, DynamicRouterInfo, RouterPriority, RouterCollectorOptions, MidwayWebRouterService, } from './service/webRouterService';
19
20
  export { MidwayServerlessFunctionService, WebRouterCollector, } from './service/slsFunctionService';
20
21
  export { DataSourceManager } from './common/dataSourceManager';
22
+ export { DEFAULT_PRIORITY, MidwayPriorityManager, } from './common/priorityManager';
21
23
  export * from './service/pipelineService';
22
24
  export * from './common/loggerFactory';
23
25
  export * from './common/serviceFactory';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.FORMAT = exports.FileUtils = exports.PathFileUtil = exports.Types = exports.retryWith = exports.retryWithAsync = exports.extend = exports.Utils = exports.sleep = exports.isTypeScriptEnvironment = exports.wrapAsync = exports.wrapMiddleware = exports.pathMatching = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.loadModule = exports.safeRequire = exports.safelyGet = exports.ASYNC_ROOT_CONTEXT = exports.DataSourceManager = exports.WebRouterCollector = exports.MidwayServerlessFunctionService = exports.MidwayWebRouterService = exports.MidwayMockService = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.FunctionalConfiguration = exports.createConfiguration = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
17
+ exports.FORMAT = exports.FileUtils = exports.PathFileUtil = exports.Types = exports.retryWith = exports.retryWithAsync = exports.extend = exports.Utils = exports.sleep = exports.isTypeScriptEnvironment = exports.wrapAsync = exports.wrapMiddleware = exports.pathMatching = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetAllPrototypeMethod = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.loadModule = exports.safeRequire = exports.safelyGet = exports.ASYNC_ROOT_CONTEXT = exports.MidwayPriorityManager = exports.DEFAULT_PRIORITY = exports.DataSourceManager = exports.WebRouterCollector = exports.MidwayServerlessFunctionService = exports.MidwayWebRouterService = exports.MidwayHealthService = exports.MidwayMockService = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.FunctionalConfiguration = exports.createConfiguration = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
18
18
  __exportStar(require("./interface"), exports);
19
19
  __exportStar(require("./context/container"), exports);
20
20
  var requestContainer_1 = require("./context/requestContainer");
@@ -46,6 +46,8 @@ var decoratorService_1 = require("./service/decoratorService");
46
46
  Object.defineProperty(exports, "MidwayDecoratorService", { enumerable: true, get: function () { return decoratorService_1.MidwayDecoratorService; } });
47
47
  var mockService_1 = require("./service/mockService");
48
48
  Object.defineProperty(exports, "MidwayMockService", { enumerable: true, get: function () { return mockService_1.MidwayMockService; } });
49
+ var healthService_1 = require("./service/healthService");
50
+ Object.defineProperty(exports, "MidwayHealthService", { enumerable: true, get: function () { return healthService_1.MidwayHealthService; } });
49
51
  var webRouterService_1 = require("./service/webRouterService");
50
52
  Object.defineProperty(exports, "MidwayWebRouterService", { enumerable: true, get: function () { return webRouterService_1.MidwayWebRouterService; } });
51
53
  var slsFunctionService_1 = require("./service/slsFunctionService");
@@ -53,6 +55,9 @@ Object.defineProperty(exports, "MidwayServerlessFunctionService", { enumerable:
53
55
  Object.defineProperty(exports, "WebRouterCollector", { enumerable: true, get: function () { return slsFunctionService_1.WebRouterCollector; } });
54
56
  var dataSourceManager_1 = require("./common/dataSourceManager");
55
57
  Object.defineProperty(exports, "DataSourceManager", { enumerable: true, get: function () { return dataSourceManager_1.DataSourceManager; } });
58
+ var priorityManager_1 = require("./common/priorityManager");
59
+ Object.defineProperty(exports, "DEFAULT_PRIORITY", { enumerable: true, get: function () { return priorityManager_1.DEFAULT_PRIORITY; } });
60
+ Object.defineProperty(exports, "MidwayPriorityManager", { enumerable: true, get: function () { return priorityManager_1.MidwayPriorityManager; } });
56
61
  __exportStar(require("./service/pipelineService"), exports);
57
62
  __exportStar(require("./common/loggerFactory"), exports);
58
63
  __exportStar(require("./common/serviceFactory"), exports);
@@ -406,6 +406,9 @@ export type ServiceFactoryConfigOption<OPTIONS> = {
406
406
  [key: string]: PowerPartial<OPTIONS>;
407
407
  };
408
408
  defaultClientName?: string;
409
+ clientPriority?: {
410
+ [key: string]: number;
411
+ };
409
412
  };
410
413
  export type CreateDataSourceInstanceOptions = {
411
414
  /**
@@ -939,6 +942,12 @@ export interface IServiceFactory<Client> {
939
942
  getName(): string;
940
943
  stop(): Promise<void>;
941
944
  getDefaultClientName(): string;
945
+ getClients(): Map<string, Client>;
946
+ getClientKeys(): string[];
947
+ getClientPriority(clientName: string): string;
948
+ isHighPriority(clientName: string): boolean;
949
+ isMediumPriority(clientName: string): boolean;
950
+ isLowPriority(clientName: string): boolean;
942
951
  }
943
952
  export interface ISimulation {
944
953
  setup?(): Promise<void>;
@@ -17,5 +17,7 @@ export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
17
17
  getLogger(name: string): any;
18
18
  getCurrentLoggerFactory(): LoggerFactory<any, any>;
19
19
  createContextLogger(ctx: IMidwayContext, appLogger: ILogger, contextOptions?: any): ILogger;
20
+ getClients(): Map<string, ILogger>;
21
+ getClientKeys(): string[];
20
22
  }
21
23
  //# sourceMappingURL=loggerService.d.ts.map
@@ -86,6 +86,12 @@ let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.Ser
86
86
  createContextLogger(ctx, appLogger, contextOptions) {
87
87
  return this.loggerFactory.createContextLogger(ctx, appLogger, contextOptions);
88
88
  }
89
+ getClients() {
90
+ return this.clients;
91
+ }
92
+ getClientKeys() {
93
+ return Array.from(this.clients.keys());
94
+ }
89
95
  };
90
96
  __decorate([
91
97
  (0, decorator_1.Inject)(),
package/dist/setup.js CHANGED
@@ -136,6 +136,7 @@ async function prepareGlobalApplicationContextAsync(globalOptions) {
136
136
  applicationContext.bindClass(_1.MidwayWebRouterService);
137
137
  applicationContext.bindClass(slsFunctionService_1.MidwayServerlessFunctionService);
138
138
  applicationContext.bindClass(healthService_1.MidwayHealthService);
139
+ applicationContext.bindClass(_1.MidwayPriorityManager);
139
140
  printStepDebugInfo('Binding preload module');
140
141
  // bind preload module
141
142
  if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
@@ -230,6 +231,7 @@ function prepareGlobalApplicationContext(globalOptions) {
230
231
  applicationContext.bindClass(_1.MidwayWebRouterService);
231
232
  applicationContext.bindClass(slsFunctionService_1.MidwayServerlessFunctionService);
232
233
  applicationContext.bindClass(healthService_1.MidwayHealthService);
234
+ applicationContext.bindClass(_1.MidwayPriorityManager);
233
235
  printStepDebugInfo('Binding preload module');
234
236
  // bind preload module
235
237
  if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.13.7",
3
+ "version": "3.14.3",
4
4
  "description": "midway core",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "engines": {
43
43
  "node": ">=12"
44
44
  },
45
- "gitHead": "8a239c69f8a711a5e71fae63148bc5f3daf95828"
45
+ "gitHead": "7517e708722bbf9ba69d9406e73fa2597e485d24"
46
46
  }