Browse Source

整理L1Svr控制器,修改连接业务后台线程池个数参数为可配置

linhong 3 years ago
parent
commit
2d65b96614

+ 2 - 52
Controllers/L1SvrController.cs

@@ -29,26 +29,6 @@ namespace LJProxy.Controllers
                 _appSettingModel = appSettingModel.Value;
             }
         }
-        private static ILJClient _PROPool { get; set; }
-        private static ILJClient PROPool
-        {
-            get
-            {
-                if (_PROPool == null)
-                {
-                    lock (_syncRoot)
-                    {
-                        var url = _appSettingModel.L1SvrPROUrl;
-                        var urlArr = url.Split(':');
-                        var ip = urlArr[0];
-                        var port = urlArr[1];
-                        var creator = new DirectP1ClientCreator(ip, Convert.ToInt32(port));
-                        _PROPool = new LJClientPool(creator, 1000);
-                    }
-                }
-                return _PROPool;
-            }
-        }
         private static ILJClient _pool { get; set; }
         private static ILJClient Pool
         {
@@ -58,44 +38,18 @@ namespace LJProxy.Controllers
                 {
                     lock (_syncRoot)
                     {
-                        var url = _appSettingModel.L1SvrCRPUrl;
+                        var url = _appSettingModel.L1SvrUrl;
                         var urlArr = url.Split(':');
                         var ip = urlArr[0];
                         var port = urlArr[1];
                         var creator = new DirectP1ClientCreator(ip, Convert.ToInt32(port));
-                        _pool = new LJClientPool(creator, 20);
+                        _pool = new LJClientPool(creator, _appSettingModel.ThreadSize);
                     }
                 }
                 return _pool;
             }
         }
 
-        //[Route("PRO/{apiName}")]
-        //[HttpPost]
-        //public string PRO(string apiName, [FromBody] object requestBody)
-        //{
-        //    var rslt = PROPool.DoExcute(apiName, requestBody.ToString());
-        //    return rslt;
-        //}
-
-        //[Route("CRP/{apiName}/{**restPath}")]
-        //[HttpPost]
-        //[HttpGet]
-        //public async Task<IActionResult> CRP(string apiName)
-        //{ 
-        //    string requestBody;
-        //    using(StreamReader reader = new StreamReader(Request.Body,Encoding.UTF8))
-        //    {
-        //        requestBody = await reader.ReadToEndAsync();
-        //    }
-        //    var excuteResult = GlobalVar.Excute(apiName, requestBody, Request);
-        //    if (excuteResult.Item1) return excuteResult.Item2;
-        //    else
-        //    {
-        //        var rslt = CRPPool.DoExcute(apiName, requestBody);
-        //        return Content(rslt,"application/json");
-        //    }
-        //}
 
         [Route("svr/{apiName}")]
         [HttpPost]
@@ -112,9 +66,5 @@ namespace LJProxy.Controllers
             var rslt = Pool.DoExcute(apiName, requestBody);
             return Content(rslt, "application/json");
         }
-
-        
-
-
     }
 }

+ 3 - 2
GlobalVar/GlobalVar.cs

@@ -48,8 +48,9 @@ namespace LJProxy
         public static void InitSetting(IConfiguration configuration)
         {
             Setting = new AppSettings();
-            Setting.L1SvrCRPUrl = configuration.GetSection("L1SvrCRPUrl")?.Value;
-            Setting.L1SvrPROUrl = configuration.GetSection("L1SvrPROUrl")?.Value;
+            Setting.L1SvrUrl = configuration.GetSection("L1SvrUrl")?.Value;
+            string threadSizeStr = configuration.GetSection("ThreadSize")?.Value;
+            Setting.ThreadSize = string.IsNullOrEmpty(threadSizeStr)?20:Convert.ToInt32(threadSizeStr);
             Setting.ProxyDomainList = configuration.GetSection("ProxyDomainList").GetChildren().Select(c => c.Value).ToList();
         }
 

+ 1 - 1
LJLib.Net.SPI.Com/LJResponse.cs

@@ -14,7 +14,7 @@ namespace LJLib.Net.SPI.Com
         /// <summary>
         /// 异常详细信息
         /// </summary>
-        //public string DebugMsg { get; set; }
+        public string DebugMsg { get; set; }
 
     }
 }

+ 0 - 46
Models/GetAppUserInfo.cs

@@ -1,46 +0,0 @@
-using LJLib.Net.SPI.Com;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Models
-{
-    public class GetAppUserInfoRequest:LJRequest
-    {
-        public string fundid { get; set; }
-        public string oldToken { get; set; }
-    }
-
-    public class GetAppUserInfoResponse : LJResponse
-    {
-        /// <summary>
-        /// 用户功能ID列表
-        /// </summary>
-        public string rsltFunids { get; set; }
-        /// <summary>
-        /// 用户语言
-        /// </summary>
-        public string langcode { get; set; }
-
-        //以下格式未定
-        /// <summary>
-        /// 用户权限列表
-        /// </summary>
-        public string userPower { get; set; }
-        /// <summary>
-        /// 用户时区
-        /// </summary>
-        public string timezone { get; set; }
-        /// <summary>
-        /// 用户所在工组的工序技能
-        /// </summary>
-        public string usercando { get; set; }
-        /// <summary>
-        /// 系统基础标签
-        /// </summary>
-        public string[] basicLabel { get; set; }
-    }
-
-
-}

+ 2 - 2
Settings/AppSettings.cs

@@ -7,8 +7,8 @@ namespace LJProxy.Settings
 {
     public class AppSettings
     {
-        public string L1SvrCRPUrl { get; set; }
-        public string L1SvrPROUrl { get; set; }
+        public string L1SvrUrl { get; set; }
+        public int ThreadSize { get; set; }
         public List<string> ProxyDomainList { get; set; }
     }
 }

+ 2 - 2
appsettings.json

@@ -1,7 +1,7 @@
 {
   "Appsettings": {
-    "L1SvrCRPUrl": "127.0.0.1:30032",
-    "L1SvrPROUrl": "192.168.0.93:30032",
+    "L1SvrUrl": "127.0.0.1:30032",
+    "ThreadSize": 20,
     "ProxyDomainList": ["192.168.0.94","l1mes.futuralimited.com"]
   },
   "Logging": {