cgserver 6.3.5 → 6.4.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.
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GAsyncQueueTool = void 0;
|
|
4
|
+
const cgserver_1 = require("../cgserver");
|
|
5
|
+
const Log_1 = require("./Log");
|
|
6
|
+
class AsyncQueueItem {
|
|
7
|
+
key = "";
|
|
8
|
+
running = false;
|
|
9
|
+
funcs = [];
|
|
10
|
+
constructor(key) {
|
|
11
|
+
this.key = key;
|
|
12
|
+
}
|
|
13
|
+
add(func) {
|
|
14
|
+
this.funcs.push(func);
|
|
15
|
+
this._run();
|
|
16
|
+
}
|
|
17
|
+
async _run() {
|
|
18
|
+
if (this.running) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.running = true;
|
|
22
|
+
while (this.funcs.length > 0) {
|
|
23
|
+
try {
|
|
24
|
+
let func = this.funcs.shift();
|
|
25
|
+
if (!func) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (cgserver_1.core.isAsyncFunc(func)) {
|
|
29
|
+
await func().catch((error) => {
|
|
30
|
+
Log_1.GLog.error(error);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
func();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
Log_1.GLog.error(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
this.running = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class AsyncQueueTool {
|
|
45
|
+
//队列数据,一个key队列必须有先后
|
|
46
|
+
_queues;
|
|
47
|
+
add(key, func) {
|
|
48
|
+
this._queues[key] = this._queues[key] || new AsyncQueueItem(key);
|
|
49
|
+
this._queues[key].add(func);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.GAsyncQueueTool = new AsyncQueueTool();
|
package/dist/lib/cgserver.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.GMongoAccountSer = exports.MongoAccountService = exports.GMysqlAccountSer = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.ServerConfig = exports.GFCfg = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = void 0;
|
|
4
|
-
exports.GCgServer = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = void 0;
|
|
4
|
+
exports.GCgServer = exports.GAsyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = void 0;
|
|
5
5
|
var ProtoFactory_1 = require("./SocketServer/ProtoFilter/ProtoFactory");
|
|
6
6
|
Object.defineProperty(exports, "GProtoFactory", { enumerable: true, get: function () { return ProtoFactory_1.GProtoFactory; } });
|
|
7
7
|
var DBCache_1 = require("./Database/Decorator/DBCache");
|
|
@@ -157,6 +157,8 @@ var Response_1 = require("./WebServer/Engine/Response");
|
|
|
157
157
|
Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return Response_1.Response; } });
|
|
158
158
|
var FrameworkConfig_2 = require("./Config/FrameworkConfig");
|
|
159
159
|
Object.defineProperty(exports, "WebServerConfig", { enumerable: true, get: function () { return FrameworkConfig_2.WebServerConfig; } });
|
|
160
|
+
var AsyncQueueTool_1 = require("./Logic/AsyncQueueTool");
|
|
161
|
+
Object.defineProperty(exports, "GAsyncQueueTool", { enumerable: true, get: function () { return AsyncQueueTool_1.GAsyncQueueTool; } });
|
|
160
162
|
const Log_2 = require("./Logic/Log");
|
|
161
163
|
class CgServer {
|
|
162
164
|
constructor() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare class AsyncQueueItem {
|
|
2
|
+
key: string;
|
|
3
|
+
running: boolean;
|
|
4
|
+
funcs: Function[];
|
|
5
|
+
constructor(key: string);
|
|
6
|
+
add(func: Function): void;
|
|
7
|
+
protected _run(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
declare class AsyncQueueTool {
|
|
10
|
+
protected _queues: {
|
|
11
|
+
[key: string]: AsyncQueueItem;
|
|
12
|
+
};
|
|
13
|
+
add(key: string, func: Function): void;
|
|
14
|
+
}
|
|
15
|
+
export declare let GAsyncQueueTool: AsyncQueueTool;
|
|
16
|
+
export {};
|
package/dist/types/cgserver.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export { RazorJs } from './WebServer/Engine/RazorJs';
|
|
|
72
72
|
export { Request } from './WebServer/Engine/Request';
|
|
73
73
|
export { Response } from './WebServer/Engine/Response';
|
|
74
74
|
export { WebServerConfig } from './Config/FrameworkConfig';
|
|
75
|
+
export { GAsyncQueueTool } from './Logic/AsyncQueueTool';
|
|
75
76
|
declare class CgServer {
|
|
76
77
|
constructor();
|
|
77
78
|
init(): void;
|