lith há 3 anos atrás
pai
commit
d39bbf7ecf

+ 210 - 37
dotnet/ServiceCenter/App.ServiceCenter.NetFx/App.ServiceCenter.NetFx/appsettings.json

@@ -1,16 +1,21 @@
 {
-
   "Sers": {
     /* 通讯层配置 */
     "CL": {
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        "workThread": {
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          "mode": "LongThread",
+          /* 后台处理消息的线程个数(单位个,默认2) */
+          "threadCount": 2,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          "timeoutMs": 300000
+        },
 
-        /* 后台处理消息的线程个数(单位个,默认2) */
-        "workThreadCount": 8,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
         //HeartBeat
         /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
@@ -19,7 +24,7 @@
         "heartBeatTimeoutMs": 30000,
         /* 心跳检测失败重试次数(单位次,默认10) */
         "heartBeatRetryCount": 10,
-     
+
 
         /* 数据传输 加密协议,可多个,可不指定 */
         "//security": [
@@ -51,9 +56,9 @@
         {
           //Ipc.NamedPipe
           /* (x.1) type */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Ipc.NamedPipe.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Ipc.NamedPipe.OrganizeServerBuilder",
 
 
@@ -64,12 +69,25 @@
         {
           // Socket.Iocp
           /* (x.1) type - Iocp */
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           "className": "Sers.CL.Socket.Iocp.OrganizeServerBuilder",
 
+          /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait  */
+          //"mode": "ThreadWait",
+
+          /* 接收缓存区大小(单位:byte,默认:8192)  */
+          //"receiveBufferSize": 8192,
+
+          /* 发送缓冲区刷新间隔(单位:毫秒,默认:1)(仅当mode为Timer和ThreadWait时有效)  */
+          //"sendFlushInterval": 1,
+          /* 发送缓冲区数据块的最小大小(单位:byte,默认 1000000)(仅当mode为Timer和ThreadWait时有效)  */
+          //"sendBufferSize": 1000000,
+          /* 发送缓冲区个数(默认1024)(仅当mode为Timer和ThreadWait时有效)    */
+          //"sendBufferCount": 1024,
+
 
           /* (x.2) config */
-          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.com"。*/
+          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
           //"host": "127.0.0.1",
           /* 服务端 监听端口号。例如: 4501 */
           "port": 4501
@@ -77,12 +95,12 @@
         {
           // Socket.ThreadWait
           /* (x.1) type - Socket */
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Socket.ThreadWait.OrganizeServerBuilder",
 
 
           /* (x.2) config */
-          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.com"。*/
+          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
           //"host": "127.0.0.1",
           /* 服务端 监听端口号。例如: 4501 */
           "port": 4501
@@ -91,9 +109,9 @@
         {
           // Zmq.ThreadWait
           /* (x.1) type */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.ClrZmq.ThreadWait.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.ClrZmq.ThreadWait.OrganizeServerBuilder",
 
 
@@ -118,9 +136,9 @@
         {
           // Zmq.FullDuplex
           /* (x.1) type */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Zmq.FullDuplex.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Zmq.FullDuplex.OrganizeServerBuilder",
 
           /* (x.2) config */
@@ -132,9 +150,9 @@
         {
           //Ipc.SharedMemory
           /* (x.1) type - Ipc.SharedMemory */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
 
 
@@ -148,9 +166,9 @@
         },
         {
           /* (x.1) type - Ipc.SharedMemory */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
 
           /* (x.2) config */
@@ -164,19 +182,28 @@
       ]
     },
 
-    /* LocalApiService 配置,可不指定 */
-    "LocalApiService": {
+    // RpcData序列化模式。可不指定。默认为Text。
+    // 可为 Newtonsoft、Text、BytePointor。
+    // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
+    "RpcDataSerializeMode": "Text",
 
-      /* 后台服务的线程个数(单位个,默认0,代表不开启服务)*/
-      "workThreadCount": 1,
 
-      /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
-      //"timeout_ms": 10000,
 
+    /* LocalApiService 配置,可不指定 */
+    "LocalApiService": {
 
       /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
       "PrintTrace": false,
 
+      "workThread": {
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        "mode": "LongThread",
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
+        "threadCount": 4,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        "timeoutMs": 300000
+      },
+
 
       /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
       "//staticFiles": [
@@ -244,7 +271,7 @@
         {
           /* 在此Assembly中加载类 */
           "assemblyFile": "Sers.ApiTrace.dll",
-          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScope */
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScopeEvent */
           "className": "Sers.ApiTrace.ApiScope"
         }
       ],
@@ -253,7 +280,7 @@
       "//BeforeCallApi": [
         {
           /* 在此Assembly中加载类 */
-          //"assemblyFile": "Sers.Core.dll",
+          "assemblyFile": "Sers.Core.dll",
           /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
           //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
@@ -321,10 +348,10 @@
 
 
       //调用api前的事件,可不指定
-      "BeforeCallApi": [
+      "//BeforeCallApi": [
         {
           /* 在此Assembly中加载类 */
-          //"assemblyFile": "Sers.Core.dll",
+          "assemblyFile": "Sers.Core.dll",
           /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
           //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
@@ -356,7 +383,8 @@
 
     /* 动态加载的App事件 */
     "AppEvent": [
-      {
+      { //记录请求Trace到Zipkin
+
         /* 在此Assembly中加载类 */
         "assemblyFile": "Sers.Gover.Apm.Zipkin.dll",
         /* 动态加载的类名,必须继承接口 Sers.Core.Module.App.AppEvent.IAppEvent */
@@ -366,21 +394,165 @@
 
         /* 配置 */
         "SamplingRate": "1.0",
-        "zipkinCollectorUrl": "http://do.sers.com:9411",
+        "zipkinCollectorUrl": "http://sers.cloud:9411",
 
         /* 若不指定则默认为ServiceCenter */
         "rpcName": "ServiceCenter",
         "tags": {
+          // 可为 requestRpc requestData responseRpc responseData
+          "traceName": "demoTrace",
+
           "route": "{{requestRpc.route}}",
           "{{requestRpc.route}}": "route",
           "url": "{{requestRpc.http.url}}",
           "method": "{{requestRpc.http.method}}",
           "requestRpc": "{{requestRpc}}",
-          "requestData": "{{requestData}}",
-          "traceName": "demoTrace"
+          //"requestData": "{{requestData}}",
+
+
+          "responseRpc": "{{responseRpc}}",
+          "responseState": "{{responseRpc.http.headers.responseState}}",
+          "responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
+
+          //"responseData": "{{responseData}}",
+          //"responseData.error": "{{responseData.error}}"
+
+        }
+      },
+      { //记录请求Trace到 Log/{yyyy-MM}/[{yyyy-MM-dd}]ApiTrace.txt文件
+
+        /* 在此Assembly中加载类 */
+        "assemblyFile": "Sers.Gover.Apm.Txt.dll",
+        /* 动态加载的类名,必须继承接口 Sers.Core.Module.App.AppEvent.IAppEvent */
+        //"className": "Sers.Gover.Apm.Txt.AppEvent",
+
+
+        "tags": {
+          // 可为 requestRpc requestData responseRpc responseData
+          "From": "Sers.Gover.Apm.Txt",
+
+          "route": "{{requestRpc.route}}",
+          //"{{requestRpc.route}}": "route",
+
+          "url": "{{requestRpc.http.url}}",
+          "method": "{{requestRpc.http.method}}",
+          "requestRpc": "{{requestRpc}}",
+          //"requestData": "{{requestData}}",
+
+
+          "responseRpc": "{{responseRpc}}",
+          "responseState": "{{responseRpc.http.headers.responseState}}"
+          //"responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
+
+          //"responseData": "{{responseData}}",
+          //"responseData.error": "{{responseData.error}}"
+
         }
       }
-    ]
+    ],
+
+
+    /* 网关配置。若不指定,则不开启网关服务 */
+    "Gateway": {
+
+      /* Rpc配置,可不指定 */
+      "Rpc": {
+        /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide")  */
+        //"CallerSource": "OutSide"
+      },
+
+      "WebHost": {
+
+        /* url,可多个 */
+        "urls": [ "http://*:4580" ],
+
+        /* 是否允许跨域访问,默认true */
+        "allowAnyOrigin": true,
+
+        /* 把请求的ip地址、端口号复制到请求头中的前缀。若不指定则不复制。 */
+        "prefixOfCopyIpToHeader": "Sers-Gateway-",
+
+        /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset  */
+        "//ResponseDefaultContentType": "application/json; charset=UTF-8",
+
+
+        /* 映射静态文件。若不指定则不映射静态文件 */
+        "staticFiles": {
+
+          /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
+          //"requestPath": "/file",
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
+          //"rootPath": "wwwroot",
+
+          /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance */
+          "defaultFileNames": [ "index.html" ],
+
+          /* 是否可浏览目录(default false)。Enables directory browsing */
+          //"useDirectoryBrowser": false,
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "contentTypeMap.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+
+      },
+
+
+      //调用api前的事件,可不指定
+      "BeforeCallApi": [
+        {
+          /* 在此Assembly中加载类 */
+          "assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
+          //"className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
+          /* 验证at接口的地址 */
+          "api_verifyAt": "/AuthCenter/account/verifyAt",
+          /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
+          "api_httpMethod": "POST"
+        },
+
+        {
+          //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
+          "className": "AccountInCookie",
+          "account": [
+            {
+              "userToken": "admin_123456",
+              "CallerSource": "Internal",
+              "userInfo": {
+                "name": "Gover管理员",
+                "入口": "Gover网关"
+              }
+            }
+          ]
+        }
+      ],
+
+
+      /* 服务限流配置,可不指定 */
+      "rateLimit": [
+        {
+          /* 服务限流key,标识一个限流服务,必须唯一 */
+          "rateLimitKey": "rate",
+
+          /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
+          "rateLimitType": "FixedWindow",
+          /* 单位时间内最大请求数量(个)*/
+          "reqLimit": 100000,
+          /* 单位时间长度(单位:ms)*/
+          "msInterval": 1000
+        }
+      ]
+
+    }
 
 
 
@@ -395,11 +567,12 @@
 
     /* 日志配置,可不指定 */
     "Logger": {
-      /* print the log to console. default:false  */
+      /* print the log to Log/*.txt default:true  */
+      "PrintToTxt": true,
+      /* print the log to console. default:true  */
       "PrintToConsole": true
     },
 
-
     /* 序列化配置,可不指定 */
     "Serialization": {
       /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */

+ 1 - 1
dotnet/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -198,7 +198,7 @@
       "workThread": {
         // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 4,
         /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
         "timeoutMs": 300000

+ 1 - 1
dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/appsettings.json

@@ -187,7 +187,7 @@
       "workThread": {
         // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 16,
         /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
         "timeoutMs": 300000

+ 1 - 1
dotnet/ServiceStation/Demo/Serslot/Did.Serslot.Demo/appsettings.json

@@ -74,7 +74,7 @@
       "workThread": {
         // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 16,
         /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
         "timeoutMs": 300000

+ 1 - 1
dotnet/ServiceStation/Demo/StressTest/App.Robot.Station/appsettings.json

@@ -160,7 +160,7 @@
       "workThread": {
         // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 4,
         /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
         "timeoutMs": 300000