cgserver 8.3.3 → 8.3.5
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/dist/lib/Framework/WebServer/Decorator/SyncCall.js +21 -1
- package/dist/lib/Framework/WebServer/Decorator/SyncCallServer.js +39 -3
- package/dist/lib/Framework/index.js +4 -1
- package/dist/types/Framework/WebServer/Decorator/SyncCall.d.ts +5 -0
- package/dist/types/Framework/WebServer/Decorator/SyncCallServer.d.ts +8 -1
- package/dist/types/Framework/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SyncCall = void 0;
|
|
3
|
+
exports.SyncCall2 = exports.SyncCall = void 0;
|
|
4
4
|
const SyncQueueTool_1 = require("../../Logic/SyncQueueTool");
|
|
5
5
|
/**
|
|
6
6
|
* 异步函数变为同步函数,当前进程有效
|
|
@@ -19,3 +19,23 @@ function SyncCall(target, propertyName, descriptor) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
exports.SyncCall = SyncCall;
|
|
22
|
+
/**
|
|
23
|
+
* 异步函数变为同步函数,当前进程有效
|
|
24
|
+
* @param param_index 动态参数的索引
|
|
25
|
+
*/
|
|
26
|
+
function SyncCall2(param_index) {
|
|
27
|
+
return (target, propertyName, descriptor) => {
|
|
28
|
+
let method = descriptor.value;
|
|
29
|
+
descriptor.value = function () {
|
|
30
|
+
let key = propertyName;
|
|
31
|
+
if (param_index != undefined && param_index < arguments.length) {
|
|
32
|
+
key = propertyName + "_" + arguments[param_index];
|
|
33
|
+
}
|
|
34
|
+
let ret = SyncQueueTool_1.GSyncQueueTool.add(key, async () => {
|
|
35
|
+
return await method.apply(target, arguments);
|
|
36
|
+
});
|
|
37
|
+
return ret;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.SyncCall2 = SyncCall2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SyncCallServer = void 0;
|
|
3
|
+
exports.SyncCallServer2 = exports.SyncCallServer = void 0;
|
|
4
4
|
const Core_1 = require("../../Core/Core");
|
|
5
5
|
const SyncQueueTool_1 = require("../../Logic/SyncQueueTool");
|
|
6
6
|
const MongoCacheService_1 = require("../../Service/MongoCacheService");
|
|
@@ -10,11 +10,47 @@ const MongoCacheService_1 = require("../../Service/MongoCacheService");
|
|
|
10
10
|
* 只支持mongo模式
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
function SyncCallServer(target, propertyName, descriptor) {
|
|
14
|
+
let method = descriptor.value;
|
|
15
|
+
descriptor.value = async () => {
|
|
16
|
+
let key = "sync_" + method.name;
|
|
17
|
+
let func = async () => {
|
|
18
|
+
let item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
19
|
+
let ret = null;
|
|
20
|
+
while (item) {
|
|
21
|
+
await Core_1.core.sleep(200);
|
|
22
|
+
item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
23
|
+
}
|
|
24
|
+
//10秒后过期,避免卡死
|
|
25
|
+
let mcm = await MongoCacheService_1.GMongoCacheSer.addData(key, true, Date.now() + 10 * 1000);
|
|
26
|
+
if (!mcm) {
|
|
27
|
+
await func();
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
};
|
|
31
|
+
await func();
|
|
32
|
+
let ret = SyncQueueTool_1.GSyncQueueTool.add(method.name, async () => {
|
|
33
|
+
return await method.apply(self, arguments);
|
|
34
|
+
});
|
|
35
|
+
await MongoCacheService_1.GMongoCacheSer.deleteOne({ key });
|
|
36
|
+
return ret;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.SyncCallServer = SyncCallServer;
|
|
40
|
+
/**
|
|
41
|
+
* 异步函数变为同步函数
|
|
42
|
+
* 服务器间的异步,效率低
|
|
43
|
+
* 只支持mongo模式
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
let SyncCallServer2 = function (params_index) {
|
|
14
47
|
return function (target, propertyName, descriptor) {
|
|
15
48
|
let method = descriptor.value;
|
|
16
49
|
descriptor.value = async () => {
|
|
17
50
|
let key = "sync_" + method.name;
|
|
51
|
+
if (params_index != undefined && params_index < arguments.length) {
|
|
52
|
+
key = key + "_" + arguments[params_index];
|
|
53
|
+
}
|
|
18
54
|
let func = async () => {
|
|
19
55
|
let item = await MongoCacheService_1.GMongoCacheSer.getData(key);
|
|
20
56
|
let ret = null;
|
|
@@ -38,4 +74,4 @@ let SyncCallServer = function () {
|
|
|
38
74
|
};
|
|
39
75
|
};
|
|
40
76
|
};
|
|
41
|
-
exports.
|
|
77
|
+
exports.SyncCallServer2 = SyncCallServer2;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.MongoAccountService = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.SqlReturns = exports.SqlReturn = exports.SqlResult = 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.GServerCfg = exports.IServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = exports.GCgServer = void 0;
|
|
4
|
-
exports.SyncCallServer = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.CgMqConfig = exports.CgMq = exports.RpcConfig = exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = 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.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = void 0;
|
|
4
|
+
exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.CgMqConfig = exports.CgMq = exports.RpcConfig = exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = 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.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = void 0;
|
|
5
|
+
exports.SyncCallServer2 = void 0;
|
|
5
6
|
var cgserver_1 = require("./cgserver");
|
|
6
7
|
Object.defineProperty(exports, "GCgServer", { enumerable: true, get: function () { return cgserver_1.GCgServer; } });
|
|
7
8
|
var ProtoFactory_1 = require("./SocketServer/ProtoFilter/ProtoFactory");
|
|
@@ -184,5 +185,7 @@ var IRpcClientWebSocket_1 = require("./SocketServer/IRpcClientWebSocket");
|
|
|
184
185
|
Object.defineProperty(exports, "IRpcClientWebSocket", { enumerable: true, get: function () { return IRpcClientWebSocket_1.IRpcClientWebSocket; } });
|
|
185
186
|
var SyncCall_1 = require("./WebServer/Decorator/SyncCall");
|
|
186
187
|
Object.defineProperty(exports, "SyncCall", { enumerable: true, get: function () { return SyncCall_1.SyncCall; } });
|
|
188
|
+
Object.defineProperty(exports, "SyncCall2", { enumerable: true, get: function () { return SyncCall_1.SyncCall2; } });
|
|
187
189
|
var SyncCallServer_1 = require("./WebServer/Decorator/SyncCallServer");
|
|
188
190
|
Object.defineProperty(exports, "SyncCallServer", { enumerable: true, get: function () { return SyncCallServer_1.SyncCallServer; } });
|
|
191
|
+
Object.defineProperty(exports, "SyncCallServer2", { enumerable: true, get: function () { return SyncCallServer_1.SyncCallServer2; } });
|
|
@@ -5,3 +5,8 @@
|
|
|
5
5
|
* @param descriptor
|
|
6
6
|
*/
|
|
7
7
|
export declare function SyncCall(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
8
|
+
/**
|
|
9
|
+
* 异步函数变为同步函数,当前进程有效
|
|
10
|
+
* @param param_index 动态参数的索引
|
|
11
|
+
*/
|
|
12
|
+
export declare function SyncCall2(param_index?: number): (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>) => void;
|
|
@@ -4,4 +4,11 @@
|
|
|
4
4
|
* 只支持mongo模式
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export declare
|
|
7
|
+
export declare function SyncCallServer(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>): void;
|
|
8
|
+
/**
|
|
9
|
+
* 异步函数变为同步函数
|
|
10
|
+
* 服务器间的异步,效率低
|
|
11
|
+
* 只支持mongo模式
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare let SyncCallServer2: (params_index?: number) => (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<Function>) => void;
|
|
@@ -82,5 +82,5 @@ export { Rpc, RpcConfig } from './ThirdParty/Rpc';
|
|
|
82
82
|
export { CgMq, CgMqConfig } from './ThirdParty/CgMq';
|
|
83
83
|
export { IRpcServerWebSocket } from './SocketServer/IRpcServerWebSocket';
|
|
84
84
|
export { IRpcClientWebSocket } from './SocketServer/IRpcClientWebSocket';
|
|
85
|
-
export { SyncCall } from './WebServer/Decorator/SyncCall';
|
|
86
|
-
export { SyncCallServer } from './WebServer/Decorator/SyncCallServer';
|
|
85
|
+
export { SyncCall, SyncCall2 } from './WebServer/Decorator/SyncCall';
|
|
86
|
+
export { SyncCallServer, SyncCallServer2 } from './WebServer/Decorator/SyncCallServer';
|